now reading tsOptions from tsConfig and supporting declaration file handling
This commit is contained in:
29
dist/npmts.compile.helpers.js
vendored
29
dist/npmts.compile.helpers.js
vendored
@ -2,30 +2,15 @@
|
||||
var plugins = require("./npmts.plugins");
|
||||
var paths = require("./npmts.paths");
|
||||
var outputPathIsDir = function (configArg, keyArg) {
|
||||
try {
|
||||
return plugins.fs.statSync(plugins.path.join(paths.cwd, configArg.ts[keyArg])).isDirectory();
|
||||
}
|
||||
catch (err) {
|
||||
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||
};
|
||||
exports.checkOutputPath = function (configArg, keyArg) {
|
||||
if (!outputPathIsDir(configArg, keyArg)) {
|
||||
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.outputNameSpecified = function (configArg, keyArg) {
|
||||
return !outputPathIsDir(configArg, keyArg)
|
||||
&& (plugins.path.extname(configArg.ts[keyArg]) == ".js");
|
||||
};
|
||||
exports.outputName = function (configArg, keyArg) {
|
||||
if (exports.outputNameSpecified(configArg, keyArg)) {
|
||||
return plugins.path.basename(configArg.ts[keyArg]);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
exports.outputDir = function (configArg, keyArg) {
|
||||
if (exports.outputNameSpecified(configArg, keyArg)) {
|
||||
return plugins.path.dirname(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||
}
|
||||
else {
|
||||
return plugins.path.join(paths.cwd, configArg.ts[keyArg]);
|
||||
return true;
|
||||
}
|
||||
;
|
||||
};
|
||||
|
34
dist/npmts.compile.js
vendored
34
dist/npmts.compile.js
vendored
@ -11,17 +11,29 @@ exports.run = function (configArg) {
|
||||
/* -------------------------------------------------
|
||||
* ----------- compile TypeScript --------------------------
|
||||
* ----------------------------------------------- */
|
||||
for (var key in config.ts) {
|
||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
|
||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||
.pipe(plugins.g.typescript({
|
||||
out: helpers.outputName(config, key),
|
||||
target: "ES5",
|
||||
module: "commonjs"
|
||||
}))
|
||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||
.pipe(plugins.gulp.dest(helpers.outputDir(config, key)));
|
||||
moduleStream.add(stream);
|
||||
var tsOptionsDefault = {
|
||||
declaration: true,
|
||||
target: "ES5",
|
||||
module: "commonjs"
|
||||
};
|
||||
/**
|
||||
* merges default ts options with those found in npmts.json
|
||||
*/
|
||||
var tsOptions = function (keyArg) {
|
||||
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions);
|
||||
};
|
||||
for (var keyArg in config.ts) {
|
||||
if (helpers.checkOutputPath(config, keyArg)) {
|
||||
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
|
||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||
.pipe(plugins.g.typescript(tsOptions(keyArg)));
|
||||
var jsStream = tsStream.js
|
||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||
var declarationStream = tsStream.dts
|
||||
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||
moduleStream.add(tsStream, jsStream, declarationStream);
|
||||
}
|
||||
}
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||
|
2
dist/npmts.options.js
vendored
2
dist/npmts.options.js
vendored
@ -28,6 +28,8 @@ exports.run = function (configArg) {
|
||||
);
|
||||
config.test = ["./index.js"];
|
||||
}
|
||||
//check if config.tsOptions is available
|
||||
config.tsOptions ? void (0) : config.tsOptions = {};
|
||||
// handle state of current build
|
||||
exports.isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
|
||||
: plugins.beautylog.info("NOT A RELEASE build!");
|
||||
|
3
dist/npmts.plugins.js
vendored
3
dist/npmts.plugins.js
vendored
@ -13,6 +13,7 @@ exports.g = {
|
||||
typescript: require("gulp-typescript"),
|
||||
typings: require("gulp-typings")
|
||||
};
|
||||
exports.lodashObject = require('lodash/fp/object');
|
||||
exports.merge2 = require("merge2");
|
||||
exports.projectinfo = require("projectinfo");
|
||||
exports.path = require("path");
|
||||
@ -24,4 +25,4 @@ exports.smartcov = require("smartcov");
|
||||
exports.smartenv = require("smartenv");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartpath = require("smartpath");
|
||||
exports.sourceMapSupport = require("source-map-support").install();
|
||||
exports.sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
||||
|
Reference in New Issue
Block a user