| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/happymandarin/node_modules/node-sass/scripts/ |
Upload File : |
/*!
* node-sass: scripts/coverage.js
*/
var Mocha = require('mocha'),
fs = require('fs'),
path = require('path'),
mkdirp = require('mkdirp'),
coveralls = require('coveralls'),
istanbul = require('istanbul'),
sourcefiles = ['index.js', 'extensions.js', 'render.js', 'errors.js'],
summary= istanbul.Report.create('text-summary'),
lcov = istanbul.Report.create('lcovonly', { dir: path.join('coverage') }),
html = istanbul.Report.create('html', { dir: path.join('coverage', 'html') });
function coverage() {
var mocha = new Mocha();
var rep = function(runner) {
runner.on('end', function(){
var cov = global.__coverage__,
collector = new istanbul.Collector();
if (cov) {
mkdirp(path.join('coverage', 'html'), function(err) {
if (err) { throw err; }
collector.add(cov);
summary.writeReport(collector, true);
html.writeReport(collector, true);
lcov.on('done', function() {
fs.readFile(path.join('coverage', 'lcov.info'), function(err, data) {
if (err) { console.error(err); }
coveralls.handleInput(data.toString(),
function (err) { if (err) { console.error(err); } });
});
});
lcov.writeReport(collector, true);
});
} else {
console.warn('No coverage');
}
});
};
var instrumenter = new istanbul.Instrumenter();
var instrumentedfiles = [];
var processfile = function(source) {
fs.readFile(path.join('lib', source), function(err, data) {
if (err) { throw err; }
mkdirp('lib-cov', function(err) {
if (err) { throw err; }
fs.writeFile(path.join('lib-cov', source),
instrumenter.instrumentSync(data.toString(),
path.join('lib', source)),
function(err) {
if (err) { throw err; }
instrumentedfiles.push(source);
if (instrumentedfiles.length === sourcefiles.length) {
fs.readdirSync('test').filter(function(file){
return file.substr(-6) === 'api.js' ||
file.substr(-11) === 'runtime.js' ||
file.substr(-7) === 'spec.js';
}).forEach(function(file){
mocha.addFile(
path.join('test', file)
);
});
process.env.NODESASS_COV = 1;
mocha.reporter(rep).run(function(failures) {
process.on('exit', function () {
process.exit(failures);
});
});
}
});
});
});
};
for (var i in sourcefiles) {
processfile(sourcefiles[i]);
}
}
/**
* Run
*/
coverage();