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;
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;

View File

@ -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 = {}));

View File

@ -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",

View File

@ -77,7 +77,7 @@
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
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>
<script src="../prettify.js"></script>

View File

@ -76,7 +76,7 @@ module.exports = testplugin;
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
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>
<script src="../prettify.js"></script>

View File

@ -77,7 +77,7 @@
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
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>
<script src="prettify.js"></script>

View File

@ -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")
},

View File

@ -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;
}
}