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