now parsing compiler options correctly

This commit is contained in:
Philipp Kunz 2016-07-27 16:08:33 +02:00
parent 3f50311487
commit f583b05f73
6 changed files with 32 additions and 19 deletions

18
dist/npmts.compile.js vendored
View File

@ -7,16 +7,22 @@ var promiseArray = [];
var compileTs = function (tsFileArrayArg, tsOptionsArg) { var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; } if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var tsOptionsDefault = { var compilerOptionsDefault = {
declaration: true, declaration: true,
target: "ES6", module: "CommonJS",
module: "commonjs" target: "ES6"
}; };
/** /**
* merges default ts options with those found in npmts.json * merges default ts options with those found in npmts.json
*/ */
var tsOptions = function (keyArg) { var compilerOptions = function (keyArg) {
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg); var tsOptionsCombined = plugins.lodashObject.merge(compilerOptionsDefault, tsOptionsArg);
var compilerOptions = {
declaration: tsOptionsCombined.declaration,
module: plugins.tsn.ModuleKind[tsOptionsCombined.module],
target: plugins.tsn.ScriptTarget[tsOptionsCombined.target]
};
return compilerOptions;
}; };
var _loop_1 = function(keyArg) { var _loop_1 = function(keyArg) {
plugins.beautylog.info("TypeScript assignment: transpile from " + keyArg.blue + " to " + tsFileArrayArg[keyArg].blue); plugins.beautylog.info("TypeScript assignment: transpile from " + keyArg.blue + " to " + tsFileArrayArg[keyArg].blue);
@ -25,7 +31,7 @@ var compileTs = function (tsFileArrayArg, tsOptionsArg) {
.then(function (filesToConvertArg) { .then(function (filesToConvertArg) {
var filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg, process.cwd()); var filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg, process.cwd());
var destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg], process.cwd()); var destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg], process.cwd());
var filesCompiledPromise = plugins.tsn.compile(filesToConvertAbsolute, destDir); var filesCompiledPromise = plugins.tsn.compile(filesToConvertAbsolute, destDir, compilerOptions(keyArg));
promiseArray.push(filesCompiledPromise); promiseArray.push(filesCompiledPromise);
}); });
promiseArray.push(filesReadPromise); promiseArray.push(filesReadPromise);

View File

@ -11,7 +11,7 @@ export declare let g: {
sourcemaps: any; sourcemaps: any;
typedoc: any; typedoc: any;
}; };
export declare let lodashObject: any; export import lodashObject = require('lodash');
export import npmextra = require("npmextra"); export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo"); export import projectinfo = require("projectinfo");
export import path = require("path"); export import path = require("path");

View File

@ -12,7 +12,7 @@ exports.g = {
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),
typedoc: require("gulp-typedoc") typedoc: require("gulp-typedoc")
}; };
exports.lodashObject = require('lodash/fp/object'); exports.lodashObject = require('lodash');
exports.npmextra = require("npmextra"); exports.npmextra = require("npmextra");
exports.projectinfo = require("projectinfo"); exports.projectinfo = require("projectinfo");
exports.path = require("path"); exports.path = require("path");

View File

@ -33,7 +33,7 @@
"@types/q": "^0.0.27", "@types/q": "^0.0.27",
"@types/shelljs": "^0.3.27", "@types/shelljs": "^0.3.27",
"babel-preset-es2015": "^6.9.0", "babel-preset-es2015": "^6.9.0",
"beautylog": "5.0.14", "beautylog": "5.0.18",
"early": "^2.0.13", "early": "^2.0.13",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-babel": "^6.1.2", "gulp-babel": "^6.1.2",
@ -46,11 +46,11 @@
"gulp-replace": "^0.5.4", "gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",
"gulp-typedoc": "^2.0.0", "gulp-typedoc": "^2.0.0",
"lodash": "^4.13.1", "lodash": "^4.14.0",
"npmextra": "^1.0.8", "npmextra": "^1.0.8",
"projectinfo": "1.0.3", "projectinfo": "1.0.3",
"q": "^1.4.1", "q": "^1.4.1",
"shelljs": "^0.7.1", "shelljs": "^0.7.2",
"smartci": "0.0.1", "smartci": "0.0.1",
"smartcli": "1.0.4", "smartcli": "1.0.4",
"smartcov": "0.0.9", "smartcov": "0.0.9",
@ -59,7 +59,7 @@
"smartpath": "3.2.2", "smartpath": "3.2.2",
"smartstring": "^2.0.15", "smartstring": "^2.0.15",
"source-map-support": "^0.4.2", "source-map-support": "^0.4.2",
"tsn": "^1.0.7", "tsn": "^1.0.9",
"typedoc": "^0.4.4", "typedoc": "^0.4.4",
"typescript": "^2.0.0-dev.20160630", "typescript": "^2.0.0-dev.20160630",
"typings-global": "*" "typings-global": "*"

View File

@ -8,17 +8,23 @@ let promiseArray = [];
let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => { let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => {
let done = plugins.Q.defer(); let done = plugins.Q.defer();
let tsOptionsDefault = { let compilerOptionsDefault = {
declaration: true, declaration: true,
target: "ES6", module: "CommonJS",
module: "commonjs" target: "ES6"
}; };
/** /**
* merges default ts options with those found in npmts.json * merges default ts options with those found in npmts.json
*/ */
let tsOptions = function (keyArg:string) { let compilerOptions = function (keyArg:string) {
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg) let tsOptionsCombined = plugins.lodashObject.merge(compilerOptionsDefault, tsOptionsArg);
let compilerOptions:plugins.tsn.CompilerOptions = {
declaration: tsOptionsCombined.declaration,
module: plugins.tsn.ModuleKind[tsOptionsCombined.module],
target: plugins.tsn.ScriptTarget[tsOptionsCombined.target]
};
return compilerOptions;
}; };
for (let keyArg in tsFileArrayArg) { for (let keyArg in tsFileArrayArg) {
plugins.beautylog.info(`TypeScript assignment: transpile from ${keyArg.blue} to ${tsFileArrayArg[keyArg].blue}`); plugins.beautylog.info(`TypeScript assignment: transpile from ${keyArg.blue} to ${tsFileArrayArg[keyArg].blue}`);
@ -29,7 +35,8 @@ let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => {
let destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg],process.cwd()); let destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg],process.cwd());
let filesCompiledPromise = plugins.tsn.compile( let filesCompiledPromise = plugins.tsn.compile(
filesToConvertAbsolute, filesToConvertAbsolute,
destDir destDir,
compilerOptions(keyArg)
); );
promiseArray.push(filesCompiledPromise); promiseArray.push(filesCompiledPromise);
}); });

View File

@ -11,7 +11,7 @@ export let g = {
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),
typedoc: require("gulp-typedoc") typedoc: require("gulp-typedoc")
}; };
export let lodashObject = require('lodash/fp/object'); export import lodashObject = require('lodash');
export import npmextra = require("npmextra"); export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo"); export import projectinfo = require("projectinfo");
export import path = require("path"); export import path = require("path");