tscoverage/dist/npmts.compile.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-03-12 09:21:16 +00:00
"use strict";
2016-05-25 03:23:48 +00:00
require("typings-global");
2016-02-19 23:53:23 +00:00
var plugins = require("./npmts.plugins");
var helpers = require("./npmts.compile.helpers");
2016-05-17 00:32:40 +00:00
var npmts_promisechain_1 = require("./npmts.promisechain");
2016-06-07 06:49:22 +00:00
var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
2016-02-22 21:22:39 +00:00
var done = plugins.Q.defer();
var tsOptionsDefault = {
declaration: true,
target: "ES5",
module: "commonjs"
};
/**
* merges default ts options with those found in npmts.json
*/
var tsOptions = function (keyArg) {
2016-06-07 06:49:22 +00:00
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg);
};
2016-06-07 06:49:22 +00:00
for (var keyArg in tsFileArrayArg) {
if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
2016-07-01 00:30:16 +00:00
var filesToConvert = plugins.smartfile.fs.listFileTree(plugins.path.resolve(keyArg), "**/*.ts");
plugins.tsn.compile(filesToConvert, tsFileArrayArg[keyArg]);
}
2016-03-12 09:21:16 +00:00
}
2016-06-07 06:49:22 +00:00
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
compileTs(config.ts, config.tsOptions)
.then(function () {
2016-06-07 06:53:47 +00:00
compileTs(config.testTs);
2016-06-07 06:49:22 +00:00
})
.then(function () {
plugins.beautylog.ok("compiled TypeScript!");
2016-07-01 00:28:34 +00:00
done.resolve(config);
2016-02-19 23:53:23 +00:00
});
return done.promise;
};