2016-05-25 03:23:48 +00:00
|
|
|
import "typings-global";
|
2016-02-19 23:53:23 +00:00
|
|
|
import plugins = require("./npmts.plugins");
|
|
|
|
import paths = require("./npmts.paths");
|
2016-04-30 03:49:53 +00:00
|
|
|
import helpers = require("./npmts.compile.helpers");
|
2016-05-17 00:32:40 +00:00
|
|
|
import {npmtsOra} from "./npmts.promisechain";
|
2016-04-30 03:49:53 +00:00
|
|
|
|
2016-06-07 06:49:22 +00:00
|
|
|
let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => {
|
2016-04-30 03:49:53 +00:00
|
|
|
let done = plugins.Q.defer();
|
2016-03-12 09:21:16 +00:00
|
|
|
|
2016-04-30 09:55:42 +00:00
|
|
|
let tsOptionsDefault = {
|
|
|
|
declaration: true,
|
|
|
|
target: "ES5",
|
|
|
|
module: "commonjs"
|
|
|
|
};
|
2016-04-30 03:49:53 +00:00
|
|
|
|
2016-04-30 09:55:42 +00:00
|
|
|
/**
|
|
|
|
* merges default ts options with those found in npmts.json
|
|
|
|
*/
|
|
|
|
let tsOptions = function (keyArg:string) {
|
2016-06-07 06:49:22 +00:00
|
|
|
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg)
|
2016-04-30 09:55:42 +00:00
|
|
|
};
|
2016-06-07 06:49:22 +00:00
|
|
|
for (let keyArg in tsFileArrayArg) {
|
|
|
|
if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) {
|
2016-06-30 01:17:24 +00:00
|
|
|
let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]);
|
2016-04-30 09:55:42 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-07 06:49:22 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
|
2016-04-30 09:55:42 +00:00
|
|
|
|
2016-06-07 06:49:22 +00:00
|
|
|
export let run = function (configArg) {
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
let config = configArg;
|
|
|
|
npmtsOra.text("now compiling " + "TypeScript".yellow);
|
|
|
|
|
|
|
|
compileTs(config.ts,config.tsOptions)
|
|
|
|
.then(() => {
|
2016-06-07 06:53:47 +00:00
|
|
|
compileTs(config.testTs);
|
2016-06-07 06:49:22 +00:00
|
|
|
})
|
|
|
|
.then(function () {
|
2016-05-17 00:32:40 +00:00
|
|
|
plugins.beautylog.ok("compiled TypeScript!");
|
2016-06-30 01:17:24 +00:00
|
|
|
done.resolve(config);
|
|
|
|
|
2016-02-09 04:39:31 +00:00
|
|
|
});
|
2016-02-19 23:53:23 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|