mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Dev: Remap coverage report
This commit is contained in:
30
script/coverage.js
Normal file
30
script/coverage.js
Normal file
@@ -0,0 +1,30 @@
|
||||
var path = require('path'),
|
||||
util = require('./util'),
|
||||
istanbul = require('istanbul');
|
||||
|
||||
var collector = new istanbul.Collector(),
|
||||
reporter = new istanbul.Reporter();
|
||||
|
||||
var remappedJson = require('../coverage/coverage-remapped.json');
|
||||
|
||||
var coverage = util.reduce(util.keys(remappedJson), function (result, source)
|
||||
{
|
||||
if (source.match(/src.*\.js$/) && source.indexOf('node_modules') < 0)
|
||||
{
|
||||
var correctPath = source.replace(path.resolve(__dirname, '../src'), path.resolve(__dirname, '../'));
|
||||
|
||||
var val = remappedJson[source];
|
||||
val.path = correctPath;
|
||||
result[correctPath] = val;
|
||||
}
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
collector.add(coverage);
|
||||
|
||||
reporter.add('html');
|
||||
reporter.write(collector, true, function ()
|
||||
{
|
||||
console.log('open coverage/index.html to see the coverage report.');
|
||||
});
|
||||
@@ -145,6 +145,12 @@
|
||||
* |------|-------|-------------------------------------|
|
||||
* |value |* |Value to check |
|
||||
* |return|boolean|True if value is correctly classified|
|
||||
*
|
||||
* ```javascript
|
||||
* isNum(5); // -> true
|
||||
* isNum(5.1); // -> true
|
||||
* isNum({}); // -> false
|
||||
* ```
|
||||
*/
|
||||
|
||||
/* dependencies
|
||||
@@ -499,5 +505,66 @@
|
||||
return exports;
|
||||
})();
|
||||
|
||||
/* ------------------------------ reduce ------------------------------ */
|
||||
|
||||
_.reduce = (function ()
|
||||
{
|
||||
/* Turn a list of values into a single value.
|
||||
*
|
||||
* |Name |Type |Desc |
|
||||
* |-------------------|------------|------------------------------|
|
||||
* |obj |object array|Collection to iterate over |
|
||||
* |[iteratee=identity]|function |Function invoked per iteration|
|
||||
* |[initial] |* |Initial value |
|
||||
* |[ctx] |* |Function context |
|
||||
* |return |* |Accumulated value |
|
||||
*
|
||||
* ```javascript
|
||||
* reduce([1, 2, 3], function (sum, n) { return sum + n }, 0); // -> 6
|
||||
* ```
|
||||
*/
|
||||
|
||||
/* dependencies
|
||||
* optimizeCb isArrLike isUndef keys
|
||||
*/
|
||||
|
||||
function exports(obj, iteratee, initial, ctx)
|
||||
{
|
||||
iteratee = optimizeCb(iteratee, ctx);
|
||||
|
||||
var i = 0, len, key;
|
||||
|
||||
if (isArrLike(obj))
|
||||
{
|
||||
if (isUndef(initial))
|
||||
{
|
||||
initial = obj[0];
|
||||
i = 1;
|
||||
}
|
||||
for (len = obj.length; i < len; i++)
|
||||
{
|
||||
initial = iteratee(initial, obj[i], i, obj);
|
||||
}
|
||||
} else
|
||||
{
|
||||
var _keys = keys(obj);
|
||||
if (isUndef(initial))
|
||||
{
|
||||
initial = obj[_keys[0]];
|
||||
i = 1;
|
||||
}
|
||||
for (len = _keys.length; i < len; i++)
|
||||
{
|
||||
key = _keys[i];
|
||||
initial = iteratee(initial, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
|
||||
return initial;
|
||||
}
|
||||
|
||||
return exports;
|
||||
})();
|
||||
|
||||
return _;
|
||||
}));
|
||||
Reference in New Issue
Block a user