remove scoping problem with gulp task names

This commit is contained in:
Philipp Kunz 2016-02-09 16:34:52 +01:00
parent cbda76c380
commit df5371187b
8 changed files with 37 additions and 34 deletions

2
index.d.ts vendored
View File

@ -10,7 +10,6 @@ declare module NpmtsPlugins {
insert: any; insert: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sequence: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;
@ -49,7 +48,6 @@ declare var plugins: {
insert: any; insert: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sequence: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;

View File

@ -14,7 +14,6 @@ var NpmtsPlugins;
insert: require("gulp-insert"), insert: require("gulp-insert"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sequence: require("gulp-sequence"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
@ -196,27 +195,31 @@ var NpmtsTests;
NpmtsTests.run = function (configArg) { NpmtsTests.run = function (configArg) {
var done = plugins.q.defer(); var done = plugins.q.defer();
var config = configArg; var config = configArg;
plugins.gulp.task('istanbul', function () { var istanbul = function () {
return plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")])
.pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul())
.pipe(plugins.g.istanbul.hookRequire()); .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()) .pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) .pipe(plugins.g.istanbul.writeReports())
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } })); .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())); .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 () { istanbul().on("finish", function () {
done.resolve(); mocha().on("finish", function () {
coveralls().on("finish", function () {
done.resolve(config);
});
}); });
}); });
plugins.gulp.start.apply(plugins.gulp, ['test']);
return done.promise; return done.promise;
}; };
})(NpmtsTests || (NpmtsTests = {})); })(NpmtsTests || (NpmtsTests = {}));

View File

@ -34,7 +34,6 @@
"gulp-insert": "0.5.0", "gulp-insert": "0.5.0",
"gulp-istanbul": "^0.10.3", "gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^2.2.0",
"gulp-sequence": "^0.4.4",
"gulp-typescript": "2.10.0", "gulp-typescript": "2.10.0",
"gulp-typings": "0.0.0", "gulp-typings": "0.0.0",
"merge2": "1.0.1", "merge2": "1.0.1",

View File

@ -77,7 +77,7 @@
</div><!-- /wrapper --> </div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'> <div class='footer quiet pad2 space-top1 center small'>
Code coverage Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 15:59:46 GMT+0100 (CET) generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 16:34:30 GMT+0100 (CET)
</div> </div>
</div> </div>
<script src="../prettify.js"></script> <script src="../prettify.js"></script>

View File

@ -76,7 +76,7 @@ module.exports = testplugin;
</div><!-- /wrapper --> </div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'> <div class='footer quiet pad2 space-top1 center small'>
Code coverage Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 15:59:46 GMT+0100 (CET) generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 16:34:30 GMT+0100 (CET)
</div> </div>
</div> </div>
<script src="../prettify.js"></script> <script src="../prettify.js"></script>

View File

@ -77,7 +77,7 @@
</div><!-- /wrapper --> </div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'> <div class='footer quiet pad2 space-top1 center small'>
Code coverage Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 15:59:46 GMT+0100 (CET) generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 16:34:30 GMT+0100 (CET)
</div> </div>
</div> </div>
<script src="prettify.js"></script> <script src="prettify.js"></script>

View File

@ -11,7 +11,6 @@ module NpmtsPlugins {
insert: require("gulp-insert"), insert: require("gulp-insert"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sequence: require("gulp-sequence"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },

View File

@ -3,37 +3,41 @@ module NpmtsTests {
export var run = function(configArg) { export var run = function(configArg) {
var done = plugins.q.defer(); var done = plugins.q.defer();
var config = configArg; var config = configArg;
plugins.gulp.task('istanbul', function () { var istanbul = function () {
return plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")])
// Covering files // Covering files
.pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul())
// Force `require` to return covered files // Force `require` to return covered files
.pipe(plugins.g.istanbul.hookRequire()); .pipe(plugins.g.istanbul.hookRequire());
}); return stream;
};
plugins.gulp.task('mocha', function () { var mocha = function () {
return plugins.gulp.src(["./test/test.js"]) var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha()) .pipe(plugins.g.mocha())
// Creating the reports after tests ran // Creating the reports after tests ran
.pipe(plugins.g.istanbul.writeReports()) .pipe(plugins.g.istanbul.writeReports())
// Enforce a coverage of at least 90% // Enforce a coverage of at least 90%
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } })); .pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
}); return stream;
};
plugins.gulp.task("coveralls",function(){ var coveralls = function(){
return plugins.gulp.src("./coverage/**/lcov.info") var stream = plugins.gulp.src("./coverage/**/lcov.info")
.pipe(plugins.g.if( .pipe(plugins.g.if(
(process.env.TRAVIS && config.coveralls), (process.env.TRAVIS && config.coveralls),
plugins.g.coveralls() plugins.g.coveralls()
)); ));
}); return stream;
};
plugins.gulp.task("test",function(){ istanbul().on("finish",function(){
plugins.g.sequence("istanbul","mocha","coveralls",function(){ mocha().on("finish",function(){
done.resolve(); coveralls().on("finish",function(){
done.resolve(config);
})
}) })
}); });
plugins.gulp.start.apply(plugins.gulp, ['test']);
return done.promise; return done.promise;
} }
} }