added sourcemap support

This commit is contained in:
Philipp Kunz 2016-02-17 01:16:21 +01:00
parent 5d6ead017b
commit f2ef982189
7 changed files with 18 additions and 0 deletions

4
index.d.ts vendored
View File

@ -9,9 +9,11 @@ declare module NpmtsPlugins {
header: any; header: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sourcemaps: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;
sourceMapSupport: any;
path: any; path: any;
q: any; q: any;
smartcli: any; smartcli: any;
@ -46,9 +48,11 @@ declare var plugins: {
header: any; header: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sourcemaps: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;
sourceMapSupport: any;
path: any; path: any;
q: any; q: any;
smartcli: any; smartcli: any;

View File

@ -13,9 +13,11 @@ var NpmtsPlugins;
header: require("gulp-header"), header: require("gulp-header"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
sourceMapSupport: require("source-map-support").install(),
path: require("path"), path: require("path"),
q: require("q"), q: require("q"),
smartcli: require("smartcli"), smartcli: require("smartcli"),
@ -166,6 +168,7 @@ var NpmtsCompile;
} }
})(); })();
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key)) var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out: outputName, out: outputName,
declaration: true, declaration: true,
@ -174,6 +177,7 @@ var NpmtsCompile;
var stream = plugins.mergeStream([ var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(outputDir)), tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
tsStream.js tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.g.header('#!/usr/bin/env node\n\n')) .pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(outputDir)) .pipe(plugins.gulp.dest(outputDir))
]); ]);

View File

@ -33,12 +33,14 @@
"gulp-header": "^1.7.1", "gulp-header": "^1.7.1",
"gulp-istanbul": "^0.10.3", "gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "2.11.0", "gulp-typescript": "2.11.0",
"gulp-typings": "0.0.0", "gulp-typings": "0.0.0",
"merge2": "1.0.1", "merge2": "1.0.1",
"q": "^1.4.1", "q": "^1.4.1",
"smartcli": "0.0.11", "smartcli": "0.0.11",
"smartfile": "0.0.11", "smartfile": "0.0.11",
"source-map-support": "^0.4.0",
"typings": "^0.6.8" "typings": "^0.6.8"
} }
} }

View File

@ -7,3 +7,5 @@ var testplugin = {
} }
}; };
module.exports = testplugin; module.exports = testplugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -10,3 +10,5 @@ describe("testplugins", function () {
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDO0FBQzVDLE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDLENBQUM7QUFDeEMsUUFBUSxDQUFDLGFBQWEsRUFBQztJQUNuQixRQUFRLENBQUMsZUFBZSxFQUFDO1FBQ3JCLEVBQUUsQ0FBQyxzQkFBc0IsRUFBQztZQUN0QixVQUFVLENBQUMsWUFBWSxFQUFFLENBQUE7UUFDN0IsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIiwiZmlsZSI6InRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -68,6 +68,7 @@ module NpmtsCompile {
})(); })();
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key)) var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out: outputName, out: outputName,
declaration: true, declaration: true,
@ -76,6 +77,7 @@ module NpmtsCompile {
var stream = plugins.mergeStream([ var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(outputDir)), tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
tsStream.js tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.g.header('#!/usr/bin/env node\n\n')) .pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(outputDir)) .pipe(plugins.gulp.dest(outputDir))
]); ]);

View File

@ -10,10 +10,12 @@ module NpmtsPlugins {
header: require("gulp-header"), header: require("gulp-header"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
sourceMapSupport:require("source-map-support").install(),
path: require("path"), path: require("path"),
q:require("q"), q:require("q"),
smartcli: require("smartcli"), smartcli: require("smartcli"),