diff --git a/index.d.ts b/index.d.ts index 514653d..1fc7df5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,6 +9,7 @@ declare module NpmtsPlugins { sequence: any; typescript: any; }; + mathjs: any; mergeStream: any; mocha: any; path: any; @@ -46,6 +47,7 @@ declare var plugins: { sequence: any; typescript: any; }; + mathjs: any; mergeStream: any; mocha: any; path: any; diff --git a/index.js b/index.js index 087e010..66dad2a 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ var NpmtsPlugins; sequence: require("gulp-sequence"), typescript: require("gulp-typescript") }, + mathjs: require("mathjs"), mergeStream: require("merge2"), mocha: require("mocha"), path: require("path"), @@ -84,19 +85,28 @@ var NpmtsCustom; * ----------- first install typings --------------- * ----------------------------------------------- */ var typingsDone = plugins.q.defer(); - var checkTypingsDone = function (indexArg, compareArray) { - if ((indexArg + 1) == compareArray.length) { + var typingsCounter = 0; + var typingsCounterAdvance = function () { + typingsCounter++; + if (typeof config.typings[typingsCounter] != "undefined") { + installTypings(); + } + else { plugins.beautylog.success("custom typings installed successfully"); typingsDone.resolve(); } }; - for (var key in config.typings) { - plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue); - plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[key]) }) + var installTypings = function () { + plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue); + plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) }) .then(function () { - checkTypingsDone(key, config.typings); + typingsCounterAdvance(); + }, function () { + plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue); + typingsCounterAdvance(); }); - } + }; + installTypings(); /* ------------------------------------------------- * ----------- second compile TS ------------------- * ----------------------------------------------- */ diff --git a/package.json b/package.json index 89489c5..c560d5a 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "gulp-sequence": "^0.4.4", "gulp-typescript": "2.10.0", "gulp-typings": "0.0.0", + "mathjs": "^2.7.0", "merge2": "1.0.1", "mocha": "^2.4.5", "q": "^1.4.1", diff --git a/test/assets/npmts.json b/test/assets/npmts.json index 6d24eef..04fe295 100644 --- a/test/assets/npmts.json +++ b/test/assets/npmts.json @@ -4,6 +4,9 @@ "./customdir/*.ts":"./" }, "typings":[ + "./ts", + "./subts1/", + "./subts2/", "./customdir" ] } \ No newline at end of file diff --git a/test/assets/subts1/typings.json b/test/assets/subts1/typings.json new file mode 100644 index 0000000..fd6d68d --- /dev/null +++ b/test/assets/subts1/typings.json @@ -0,0 +1,7 @@ +{ + "ambientDependencies": { + "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777", + "colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d", + "vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777" + } +} diff --git a/ts/npmts.custom.ts b/ts/npmts.custom.ts index df17be0..697fc13 100644 --- a/ts/npmts.custom.ts +++ b/ts/npmts.custom.ts @@ -10,19 +10,27 @@ module NpmtsCustom { * ----------- first install typings --------------- * ----------------------------------------------- */ var typingsDone = plugins.q.defer(); - var checkTypingsDone = function(indexArg:number,compareArray){ - if((indexArg + 1) == compareArray.length){ + var typingsCounter:number = 0; + var typingsCounterAdvance = function(){ + typingsCounter++; + if(typeof config.typings[typingsCounter] != "undefined"){ + installTypings(); + } else { plugins.beautylog.success("custom typings installed successfully"); typingsDone.resolve(); } }; - for (var key in config.typings) { - plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue); - plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[key])}) + var installTypings = function() { + plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue); + plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])}) .then(function(){ - checkTypingsDone(key,config.typings); + typingsCounterAdvance(); + },function(){ + plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue); + typingsCounterAdvance(); }); - } + }; + installTypings(); /* ------------------------------------------------- * ----------- second compile TS ------------------- * ----------------------------------------------- */ diff --git a/ts/npmts.plugins.ts b/ts/npmts.plugins.ts index 039e92b..5e5f7b2 100644 --- a/ts/npmts.plugins.ts +++ b/ts/npmts.plugins.ts @@ -11,6 +11,7 @@ module NpmtsPlugins { typescript: require("gulp-typescript") }, + mathjs: require("mathjs"), mergeStream: require("merge2"), mocha: require("mocha"), path: require("path"),