Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
1ada5dd5a9 | |||
a41bfd442c | |||
2917b10ffb | |||
bfc5bbbbb7 | |||
cf507a4a17 | |||
73a57ed264 | |||
39b79b679c | |||
cc053ee396 | |||
df5371187b | |||
cbda76c380 | |||
e20bcec133 |
@ -1,6 +1,9 @@
|
||||
# npmts
|
||||
Write npm modules with TypeScript without hassle.
|
||||
|
||||
## Status
|
||||
[](https://coveralls.io/github/pushrocks/npmts?branch=master)
|
||||
|
||||
## How to use npmts
|
||||
|
||||
### Install
|
||||
|
4
index.d.ts
vendored
4
index.d.ts
vendored
@ -6,11 +6,9 @@ declare module NpmtsPlugins {
|
||||
gulp: any;
|
||||
g: {
|
||||
coveralls: any;
|
||||
if: any;
|
||||
insert: any;
|
||||
istanbul: any;
|
||||
mocha: any;
|
||||
sequence: any;
|
||||
typescript: any;
|
||||
};
|
||||
mergeStream: any;
|
||||
@ -45,11 +43,9 @@ declare var plugins: {
|
||||
gulp: any;
|
||||
g: {
|
||||
coveralls: any;
|
||||
if: any;
|
||||
insert: any;
|
||||
istanbul: any;
|
||||
mocha: any;
|
||||
sequence: any;
|
||||
typescript: any;
|
||||
};
|
||||
mergeStream: any;
|
||||
|
39
index.js
39
index.js
@ -10,11 +10,9 @@ var NpmtsPlugins;
|
||||
gulp: require("gulp"),
|
||||
g: {
|
||||
coveralls: require("gulp-coveralls"),
|
||||
if: require("gulp-if"),
|
||||
insert: require("gulp-insert"),
|
||||
istanbul: require("gulp-istanbul"),
|
||||
mocha: require("gulp-mocha"),
|
||||
sequence: require("gulp-sequence"),
|
||||
typescript: require("gulp-typescript")
|
||||
},
|
||||
mergeStream: require("merge2"),
|
||||
@ -182,7 +180,7 @@ var NpmtsCompile;
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||
moduleStream.on("finish", function () {
|
||||
done.resolve();
|
||||
done.resolve(config);
|
||||
});
|
||||
moduleStream.end();
|
||||
});
|
||||
@ -196,27 +194,36 @@ 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 } }));
|
||||
return stream;
|
||||
};
|
||||
var coveralls = function () {
|
||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
||||
.pipe(plugins.g.coveralls());
|
||||
return stream;
|
||||
};
|
||||
istanbul().on("finish", function () {
|
||||
mocha().on("finish", function () {
|
||||
if (process.env.TRAVIS && config.coveralls) {
|
||||
coveralls().on("finish", function () {
|
||||
done.resolve(config);
|
||||
});
|
||||
plugins.gulp.task("coveralls", function () {
|
||||
return 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();
|
||||
}
|
||||
else {
|
||||
done.resolve(config);
|
||||
}
|
||||
});
|
||||
});
|
||||
plugins.gulp.start.apply(plugins.gulp, ['test']);
|
||||
return done.promise;
|
||||
};
|
||||
})(NpmtsTests || (NpmtsTests = {}));
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "npmts",
|
||||
"version": "2.1.7",
|
||||
"version": "2.2.1",
|
||||
"description": "write npm modules with TypeScript",
|
||||
"main": "index.js",
|
||||
"typings": "./index.d.ts",
|
||||
@ -30,11 +30,9 @@
|
||||
"fs-extra": "^0.26.5",
|
||||
"gulp": "3.9.0",
|
||||
"gulp-coveralls": "^0.1.4",
|
||||
"gulp-if": "^2.0.0",
|
||||
"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",
|
||||
|
@ -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 06:01:01 GMT+0100 (CET)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 17:25:54 GMT+0100 (CET)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
@ -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 06:01:01 GMT+0100 (CET)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 17:25:54 GMT+0100 (CET)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
@ -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 06:01:01 GMT+0100 (CET)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 17:25:54 GMT+0100 (CET)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
|
@ -9,5 +9,5 @@
|
||||
"./subts2/",
|
||||
"./customdir"
|
||||
],
|
||||
"coveralls":"false"
|
||||
"coveralls":true
|
||||
}
|
@ -83,7 +83,7 @@ module NpmtsCompile {
|
||||
moduleStream.on("queueDrain",function(){
|
||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||
moduleStream.on("finish",function(){
|
||||
done.resolve();
|
||||
done.resolve(config);
|
||||
});
|
||||
moduleStream.end();
|
||||
});
|
||||
|
@ -4,7 +4,7 @@ module NpmtsOptions {
|
||||
var done = plugins.q.defer();
|
||||
var config = configArg;
|
||||
if (typeof config.coveralls === "undefined"){
|
||||
config.coveralls = true;
|
||||
config.coveralls = false;
|
||||
}
|
||||
if (config.mode == "default"){
|
||||
config.typings = [
|
||||
|
@ -7,11 +7,9 @@ module NpmtsPlugins {
|
||||
gulp: require("gulp"),
|
||||
g: {
|
||||
coveralls: require("gulp-coveralls"),
|
||||
if: require("gulp-if"),
|
||||
insert: require("gulp-insert"),
|
||||
istanbul: require("gulp-istanbul"),
|
||||
mocha: require("gulp-mocha"),
|
||||
sequence: require("gulp-sequence"),
|
||||
typescript: require("gulp-typescript")
|
||||
|
||||
},
|
||||
|
@ -3,37 +3,42 @@ 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')
|
||||
.pipe(plugins.g.if(
|
||||
(process.env.TRAVIS && config.coveralls),
|
||||
plugins.g.coveralls()
|
||||
));
|
||||
});
|
||||
var coveralls = function(){
|
||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
||||
.pipe(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(){
|
||||
if(process.env.TRAVIS && config.coveralls){
|
||||
coveralls().on("finish",function(){
|
||||
done.resolve(config);
|
||||
})
|
||||
} else {
|
||||
done.resolve(config);
|
||||
}
|
||||
})
|
||||
});
|
||||
plugins.gulp.start.apply(plugins.gulp, ['test']);
|
||||
return done.promise;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user