2016-02-19 23:53:23 +00:00
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
import plugins = require("./npmts.plugins");
|
|
|
|
import paths = require("./npmts.paths");
|
2016-03-26 13:08:48 +00:00
|
|
|
|
|
|
|
export let publishCoverage = function(configArg){
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
plugins.beautylog.log("now uploading coverage data to coveralls");
|
|
|
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
|
|
|
.pipe(plugins.g.coveralls())
|
2016-03-26 16:25:45 +00:00
|
|
|
.pipe(plugins.g.gFunction(function(){
|
|
|
|
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
|
|
|
|
done.resolve(configArg);
|
|
|
|
},"atEnd"));
|
2016-03-26 13:08:48 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
2016-02-19 23:53:23 +00:00
|
|
|
export var run = function(configArg) {
|
2016-02-22 21:22:39 +00:00
|
|
|
var done = plugins.Q.defer();
|
2016-02-19 23:53:23 +00:00
|
|
|
var config = configArg;
|
|
|
|
var istanbul = function () {
|
|
|
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
|
|
|
// Covering files
|
|
|
|
.pipe(plugins.g.istanbul())
|
|
|
|
// Force `require` to return covered files
|
|
|
|
.pipe(plugins.g.istanbul.hookRequire());
|
|
|
|
return stream;
|
|
|
|
};
|
2016-02-09 04:39:31 +00:00
|
|
|
|
2016-02-19 23:53:23 +00:00
|
|
|
var mocha = function () {
|
|
|
|
var stream = plugins.gulp.src(["./test/test.js"])
|
|
|
|
.pipe(plugins.g.mocha())
|
|
|
|
// Creating the reports after tests ran
|
|
|
|
.pipe(plugins.g.istanbul.writeReports())
|
|
|
|
// Enforce a coverage of at least 90%
|
|
|
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
|
|
|
return stream;
|
|
|
|
};
|
2016-02-09 04:39:31 +00:00
|
|
|
|
2016-03-12 09:21:16 +00:00
|
|
|
plugins.beautylog.log("now starting tests");
|
2016-03-26 17:06:29 +00:00
|
|
|
console.log(
|
|
|
|
"--------------------------------------------------\n" +
|
|
|
|
"******************* TESTS: **********************\n" +
|
|
|
|
"--------------------------------------------------"
|
|
|
|
);
|
2016-02-19 23:53:23 +00:00
|
|
|
istanbul().on("finish",function(){
|
|
|
|
mocha().on("finish",function(){
|
2016-03-26 13:08:48 +00:00
|
|
|
plugins.beautylog.ok("Tests have passed!");
|
|
|
|
done.resolve(config);
|
2016-02-19 23:53:23 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
};
|