diff --git a/dist/npmts.options.js b/dist/npmts.options.js
index 156fdfa..6a50d58 100644
--- a/dist/npmts.options.js
+++ b/dist/npmts.options.js
@@ -33,6 +33,7 @@ exports.run = function (configArg) {
// handle coveralls
config.coveralls ? void (0) : config.coveralls = false;
exports.doPublish() ? void (0) : config.coveralls = false;
+ config.coverageTreshold ? void (0) : config.coverageTreshold = 70;
// handle docs
config.docs ? void (0) : config.docs = {};
config.docs.publish ? void (0) : config.docs.publish = false;
diff --git a/dist/npmts.paths.js b/dist/npmts.paths.js
index f814497..1e8a8fe 100644
--- a/dist/npmts.paths.js
+++ b/dist/npmts.paths.js
@@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd, "ts/");
paths.distDir = plugins.path.join(paths.cwd, "dist/");
paths.docsDir = plugins.path.join(paths.cwd, "docs/");
paths.testDir = plugins.path.join(paths.cwd, "test/");
+paths.coverageDir = plugins.path.join(paths.cwd, "coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
//Files
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
diff --git a/dist/npmts.plugins.js b/dist/npmts.plugins.js
index 60f1b8f..2484a09 100644
--- a/dist/npmts.plugins.js
+++ b/dist/npmts.plugins.js
@@ -21,6 +21,7 @@ exports.Q = require("q");
exports.shelljs = require("shelljs");
exports.smartci = require("smartci");
exports.smartcli = require("smartcli");
+exports.smartcov = require("smartcov");
exports.smartenv = require("smartenv");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");
diff --git a/dist/npmts.tests.js b/dist/npmts.tests.js
index 1809acc..6e44314 100644
--- a/dist/npmts.tests.js
+++ b/dist/npmts.tests.js
@@ -13,33 +13,65 @@ exports.publishCoverage = function (configArg) {
}, "atEnd"));
return done.promise;
};
+/**
+ *
+ * @returns {*}
+ */
+var istanbul = function (configArg) {
+ var 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 {*}
+ */
+var mocha = function (configArg) {
+ var done = plugins.Q.defer();
+ var 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;
+};
+var coverage = function (configArg) {
+ var 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("your coverage of " + percentageArg + "% " + "is within your treshold of " +
+ configArg.coverageTreshold + "%");
+ }
+ 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;
+};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
- var istanbul = function () {
- var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
- .pipe(plugins.g.istanbul())
- .pipe(plugins.g.istanbul.hookRequire());
- return stream;
- };
- var mocha = function () {
- var stream = plugins.gulp.src(["./test/test.js"])
- .pipe(plugins.g.mocha())
- .pipe(plugins.g.istanbul.writeReports())
- .pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
- return stream;
- };
plugins.beautylog.log("now starting tests");
console.log("--------------------------------------------------------------\n" +
"***************************" +
" TESTS: ".blue +
"***************************\n" +
"--------------------------------------------------------------");
- istanbul().on("finish", function () {
- mocha().on("finish", function () {
- plugins.beautylog.ok("Tests have passed!");
- done.resolve(config);
- });
- });
+ istanbul(config)
+ .then(mocha)
+ .then(coverage)
+ .then(done.resolve);
return done.promise;
};
diff --git a/package.json b/package.json
index a8e6ce5..e3807c9 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"gulp": "3.9.1",
"gulp-concat": "^2.6.0",
"gulp-coveralls": "^0.1.4",
- "gulp-function": "^1.1.1",
+ "gulp-function": "^1.2.0",
"gulp-if": "^2.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-jsdoc3": "^0.2.1",
@@ -44,9 +44,10 @@
"shelljs": "^0.6.0",
"smartci": "0.0.1",
"smartcli": "0.0.11",
+ "smartcov": "0.0.3",
"smartenv": "1.2.0",
"smartfile": "2.2.0",
- "smartpath": "3.0.1",
+ "smartpath": "3.0.3",
"source-map-support": "^0.4.0"
},
"devDependencies": {}
diff --git a/test/assets/dist/index.js b/test/assets/dist/index.js
index bb265ec..4ec8adb 100644
--- a/test/assets/dist/index.js
+++ b/test/assets/dist/index.js
@@ -6,4 +6,4 @@ var testplugin = {
};
module.exports = testplugin;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
diff --git a/test/assets/test/test.d.ts b/test/assets/test/test.d.ts
deleted file mode 100644
index cca223f..0000000
--- a/test/assets/test/test.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-///
-declare var testplugin: any;
diff --git a/test/assets/test/test.js b/test/assets/test/test.js
index 4bcf585..7b80e8a 100644
--- a/test/assets/test/test.js
+++ b/test/assets/test/test.js
@@ -7,4 +7,5 @@ describe("testplugins", function () {
});
});
});
-//# sourceMappingURL=test.js.map
\ No newline at end of file
+
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
diff --git a/test/assets/ts/index.ts b/test/assets/ts/index.ts
index 75b4356..c8fa281 100644
--- a/test/assets/ts/index.ts
+++ b/test/assets/ts/index.ts
@@ -1,5 +1,5 @@
///
-var testplugin = {
+let testplugin = {
logSomething: function(){
console.log("only function executed");
}
diff --git a/ts/npmts.options.ts b/ts/npmts.options.ts
index 47e038a..70b16e9 100644
--- a/ts/npmts.options.ts
+++ b/ts/npmts.options.ts
@@ -40,6 +40,8 @@ export var run = function(configArg){
config.coveralls ? void(0) : config.coveralls = false;
doPublish() ? void(0) : config.coveralls = false;
+ config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
+
// handle docs
config.docs ? void(0) : config.docs = {};
config.docs.publish ? void(0) : config.docs.publish = false;
diff --git a/ts/npmts.paths.ts b/ts/npmts.paths.ts
index 1b6b8e4..b38444c 100644
--- a/ts/npmts.paths.ts
+++ b/ts/npmts.paths.ts
@@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd,"ts/");
paths.distDir = plugins.path.join(paths.cwd,"dist/");
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
paths.testDir = plugins.path.join(paths.cwd,"test/");
+paths.coverageDir = plugins.path.join(paths.cwd,"coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
diff --git a/ts/npmts.plugins.ts b/ts/npmts.plugins.ts
index aaa8ece..1df4522 100644
--- a/ts/npmts.plugins.ts
+++ b/ts/npmts.plugins.ts
@@ -21,6 +21,7 @@ export let Q = require("q");
export let shelljs = require("shelljs");
export let smartci = require("smartci");
export let smartcli = require("smartcli");
+export let smartcov = require("smartcov");
export let smartenv = require("smartenv");
export let smartfile = require("smartfile");
export let smartpath = require("smartpath");
\ No newline at end of file
diff --git a/ts/npmts.publish.ts b/ts/npmts.publish.ts
index 5c4d58d..9f2887e 100644
--- a/ts/npmts.publish.ts
+++ b/ts/npmts.publish.ts
@@ -8,7 +8,6 @@ import NpmtsJsdoc = require("./npmts.jsdoc");
export let run = function(configArg){
let done = plugins.Q.defer();
let config = configArg;
-
let promiseArray = [];
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0);
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
diff --git a/ts/npmts.tests.ts b/ts/npmts.tests.ts
index f5f45ea..c215b13 100644
--- a/ts/npmts.tests.ts
+++ b/ts/npmts.tests.ts
@@ -14,27 +14,62 @@ export let publishCoverage = function(configArg){
return done.promise;
};
-export var run = function(configArg) {
- var done = plugins.Q.defer();
- 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;
- };
+/**
+ *
+ * @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;
+};
- 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;
- };
+/**
+ *
+ * @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;
+};
+
+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(
+ "your coverage of " + percentageArg + "% " + "is within your treshold of " +
+ configArg.coverageTreshold + "%"
+ );
+ } 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;
plugins.beautylog.log("now starting tests");
console.log(
@@ -44,11 +79,10 @@ export var run = function(configArg) {
"***************************\n" +
"--------------------------------------------------------------"
);
- istanbul().on("finish",function(){
- mocha().on("finish",function(){
- plugins.beautylog.ok("Tests have passed!");
- done.resolve(config);
- })
- });
+
+ istanbul(config)
+ .then(mocha)
+ .then(coverage)
+ .then(done.resolve);
return done.promise;
};
\ No newline at end of file
diff --git a/ts/typings.json b/ts/typings.json
index fd6d68d..aff7dc7 100644
--- a/ts/typings.json
+++ b/ts/typings.json
@@ -1,7 +1,8 @@
{
"ambientDependencies": {
- "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
+ "istanbul": "registry:dt/istanbul#0.4.0+20160316155526",
+ "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}