From df5371187babfaf36cfb1a8e87b958ab5a2aa6f3 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Tue, 9 Feb 2016 16:34:52 +0100 Subject: [PATCH] remove scoping problem with gulp task names --- index.d.ts | 2 -- index.js | 31 ++++++++++--------- package.json | 1 - .../coverage/lcov-report/assets/index.html | 2 +- .../coverage/lcov-report/assets/index.js.html | 2 +- test/assets/coverage/lcov-report/index.html | 2 +- ts/npmts.plugins.ts | 1 - ts/npmts.tests.ts | 30 ++++++++++-------- 8 files changed, 37 insertions(+), 34 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7f752c9..42d79ce 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,7 +10,6 @@ declare module NpmtsPlugins { insert: any; istanbul: any; mocha: any; - sequence: any; typescript: any; }; mergeStream: any; @@ -49,7 +48,6 @@ declare var plugins: { insert: any; istanbul: any; mocha: any; - sequence: any; typescript: any; }; mergeStream: any; diff --git a/index.js b/index.js index d03426e..a80e876 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,6 @@ var NpmtsPlugins; insert: require("gulp-insert"), istanbul: require("gulp-istanbul"), mocha: require("gulp-mocha"), - sequence: require("gulp-sequence"), typescript: require("gulp-typescript") }, mergeStream: require("merge2"), @@ -196,27 +195,31 @@ var NpmtsTests; NpmtsTests.run = function (configArg) { var done = plugins.q.defer(); var config = configArg; - plugins.gulp.task('istanbul', function () { - return plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")]) + var istanbul = function () { + var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")]) .pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul.hookRequire()); - }); - plugins.gulp.task('mocha', function () { - return plugins.gulp.src(["./test/test.js"]) + 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 } })); - }); - plugins.gulp.task("coveralls", function () { - return plugins.gulp.src("./coverage/**/lcov.info") + return stream; + }; + var coveralls = function () { + var stream = plugins.gulp.src("./coverage/**/lcov.info") .pipe(plugins.g.if((process.env.TRAVIS && config.coveralls), plugins.g.coveralls())); - }); - plugins.gulp.task("test", function () { - plugins.g.sequence("istanbul", "mocha", "coveralls", function () { - done.resolve(); + return stream; + }; + istanbul().on("finish", function () { + mocha().on("finish", function () { + coveralls().on("finish", function () { + done.resolve(config); + }); }); }); - plugins.gulp.start.apply(plugins.gulp, ['test']); return done.promise; }; })(NpmtsTests || (NpmtsTests = {})); diff --git a/package.json b/package.json index 446fe9c..d00bccd 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "gulp-insert": "0.5.0", "gulp-istanbul": "^0.10.3", "gulp-mocha": "^2.2.0", - "gulp-sequence": "^0.4.4", "gulp-typescript": "2.10.0", "gulp-typings": "0.0.0", "merge2": "1.0.1", diff --git a/test/assets/coverage/lcov-report/assets/index.html b/test/assets/coverage/lcov-report/assets/index.html index 1270027..e0f3cc5 100644 --- a/test/assets/coverage/lcov-report/assets/index.html +++ b/test/assets/coverage/lcov-report/assets/index.html @@ -77,7 +77,7 @@ diff --git a/test/assets/coverage/lcov-report/assets/index.js.html b/test/assets/coverage/lcov-report/assets/index.js.html index d88676e..5f680d4 100644 --- a/test/assets/coverage/lcov-report/assets/index.js.html +++ b/test/assets/coverage/lcov-report/assets/index.js.html @@ -76,7 +76,7 @@ module.exports = testplugin; diff --git a/test/assets/coverage/lcov-report/index.html b/test/assets/coverage/lcov-report/index.html index 19db203..eba4ff0 100644 --- a/test/assets/coverage/lcov-report/index.html +++ b/test/assets/coverage/lcov-report/index.html @@ -77,7 +77,7 @@ diff --git a/ts/npmts.plugins.ts b/ts/npmts.plugins.ts index 6d12610..1245da3 100644 --- a/ts/npmts.plugins.ts +++ b/ts/npmts.plugins.ts @@ -11,7 +11,6 @@ module NpmtsPlugins { insert: require("gulp-insert"), istanbul: require("gulp-istanbul"), mocha: require("gulp-mocha"), - sequence: require("gulp-sequence"), typescript: require("gulp-typescript") }, diff --git a/ts/npmts.tests.ts b/ts/npmts.tests.ts index 17938e7..271a387 100644 --- a/ts/npmts.tests.ts +++ b/ts/npmts.tests.ts @@ -3,37 +3,41 @@ module NpmtsTests { export var run = function(configArg) { var done = plugins.q.defer(); var config = configArg; - plugins.gulp.task('istanbul', function () { - return plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")]) + var istanbul = function () { + var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")]) // Covering files .pipe(plugins.g.istanbul()) // Force `require` to return covered files .pipe(plugins.g.istanbul.hookRequire()); - }); + return stream; + }; - plugins.gulp.task('mocha', function () { - return plugins.gulp.src(["./test/test.js"]) + 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; + }; - plugins.gulp.task("coveralls",function(){ - return plugins.gulp.src("./coverage/**/lcov.info") + var coveralls = function(){ + var stream = plugins.gulp.src("./coverage/**/lcov.info") .pipe(plugins.g.if( (process.env.TRAVIS && config.coveralls), plugins.g.coveralls() )); - }); + return stream; + }; - plugins.gulp.task("test",function(){ - plugins.g.sequence("istanbul","mocha","coveralls",function(){ - done.resolve(); + istanbul().on("finish",function(){ + mocha().on("finish",function(){ + coveralls().on("finish",function(){ + done.resolve(config); + }) }) }); - plugins.gulp.start.apply(plugins.gulp, ['test']); return done.promise; } } \ No newline at end of file