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-05-17 00:32:40 +00:00
|
|
|
import {npmtsOra} from "./npmts.promisechain";
|
2016-03-26 13:08:48 +00:00
|
|
|
|
|
|
|
export let publishCoverage = function(configArg){
|
|
|
|
let done = plugins.Q.defer();
|
2016-04-04 14:57:09 +00:00
|
|
|
plugins.beautylog.log("now uploading coverage data to codecov.io");
|
2016-03-26 13:08:48 +00:00
|
|
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
2016-04-02 17:09:11 +00:00
|
|
|
.pipe(plugins.g.codecov())
|
2016-03-26 16:25:45 +00:00
|
|
|
.pipe(plugins.g.gFunction(function(){
|
2016-04-04 14:57:09 +00:00
|
|
|
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
|
2016-03-26 16:25:45 +00:00
|
|
|
done.resolve(configArg);
|
|
|
|
},"atEnd"));
|
2016-03-26 13:08:48 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
2016-03-29 23:32:41 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
let istanbul = function (configArg) {
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
|
|
|
.pipe(plugins.g.istanbul()) // Covering files
|
|
|
|
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
|
|
|
.pipe(plugins.g.gFunction(function(){
|
|
|
|
done.resolve(configArg);
|
|
|
|
},"atEnd"));
|
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
let mocha = function (configArg) {
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
let stream = plugins.gulp.src(["./test/test.js"])
|
|
|
|
.pipe(plugins.g.mocha())
|
|
|
|
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
|
|
|
.pipe(plugins.g.gFunction(function(){
|
|
|
|
plugins.beautylog.ok("Tests have passed!");
|
|
|
|
done.resolve(configArg);
|
|
|
|
},"atEnd"));
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-02-09 04:39:31 +00:00
|
|
|
|
2016-03-29 23:32:41 +00:00
|
|
|
let coverage = function(configArg){
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
|
|
|
|
.then(function(percentageArg){
|
|
|
|
if (percentageArg >= configArg.coverageTreshold){
|
|
|
|
plugins.beautylog.ok(
|
2016-03-30 13:26:53 +00:00
|
|
|
"your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
|
|
|
|
configArg.coverageTreshold.toString().blue + "%".blue
|
2016-03-29 23:32:41 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
plugins.beautylog.warn(
|
|
|
|
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
|
|
|
|
configArg.coverageTreshold + "%"
|
|
|
|
);
|
|
|
|
plugins.beautylog.error("exiting due to coverage failure");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
done.resolve(configArg);
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
export let run = function(configArg) {
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
let config = configArg;
|
2016-02-09 04:39:31 +00:00
|
|
|
|
2016-05-17 00:32:40 +00:00
|
|
|
npmtsOra.text("now starting tests");
|
|
|
|
plugins.beautylog.log(
|
|
|
|
"-------------------------------------------------------\n" +
|
|
|
|
"*************************** TESTS: ***************************\n" +
|
2016-03-27 10:32:55 +00:00
|
|
|
"--------------------------------------------------------------"
|
2016-03-26 17:06:29 +00:00
|
|
|
);
|
2016-03-29 23:32:41 +00:00
|
|
|
|
|
|
|
istanbul(config)
|
|
|
|
.then(mocha)
|
|
|
|
.then(coverage)
|
|
|
|
.then(done.resolve);
|
2016-02-19 23:53:23 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|