now handles multiple typings recursivly

This commit is contained in:
Philipp Kunz 2016-02-06 18:56:42 +01:00
parent 4b2c0fe461
commit 0dc307f082
7 changed files with 46 additions and 14 deletions

2
index.d.ts vendored
View File

@ -9,6 +9,7 @@ declare module NpmtsPlugins {
sequence: any; sequence: any;
typescript: any; typescript: any;
}; };
mathjs: any;
mergeStream: any; mergeStream: any;
mocha: any; mocha: any;
path: any; path: any;
@ -46,6 +47,7 @@ declare var plugins: {
sequence: any; sequence: any;
typescript: any; typescript: any;
}; };
mathjs: any;
mergeStream: any; mergeStream: any;
mocha: any; mocha: any;
path: any; path: any;

View File

@ -13,6 +13,7 @@ var NpmtsPlugins;
sequence: require("gulp-sequence"), sequence: require("gulp-sequence"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mathjs: require("mathjs"),
mergeStream: require("merge2"), mergeStream: require("merge2"),
mocha: require("mocha"), mocha: require("mocha"),
path: require("path"), path: require("path"),
@ -84,19 +85,28 @@ var NpmtsCustom;
* ----------- first install typings --------------- * ----------- first install typings ---------------
* ----------------------------------------------- */ * ----------------------------------------------- */
var typingsDone = plugins.q.defer(); var typingsDone = plugins.q.defer();
var checkTypingsDone = function (indexArg, compareArray) { var typingsCounter = 0;
if ((indexArg + 1) == compareArray.length) { var typingsCounterAdvance = function () {
typingsCounter++;
if (typeof config.typings[typingsCounter] != "undefined") {
installTypings();
}
else {
plugins.beautylog.success("custom typings installed successfully"); plugins.beautylog.success("custom typings installed successfully");
typingsDone.resolve(); typingsDone.resolve();
} }
}; };
for (var key in config.typings) { var installTypings = function () {
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue); 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[key]) }) plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
.then(function () { .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 ------------------- * ----------- second compile TS -------------------
* ----------------------------------------------- */ * ----------------------------------------------- */

View File

@ -33,6 +33,7 @@
"gulp-sequence": "^0.4.4", "gulp-sequence": "^0.4.4",
"gulp-typescript": "2.10.0", "gulp-typescript": "2.10.0",
"gulp-typings": "0.0.0", "gulp-typings": "0.0.0",
"mathjs": "^2.7.0",
"merge2": "1.0.1", "merge2": "1.0.1",
"mocha": "^2.4.5", "mocha": "^2.4.5",
"q": "^1.4.1", "q": "^1.4.1",

View File

@ -4,6 +4,9 @@
"./customdir/*.ts":"./" "./customdir/*.ts":"./"
}, },
"typings":[ "typings":[
"./ts",
"./subts1/",
"./subts2/",
"./customdir" "./customdir"
] ]
} }

View File

@ -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"
}
}

View File

@ -10,19 +10,27 @@ module NpmtsCustom {
* ----------- first install typings --------------- * ----------- first install typings ---------------
* ----------------------------------------------- */ * ----------------------------------------------- */
var typingsDone = plugins.q.defer(); var typingsDone = plugins.q.defer();
var checkTypingsDone = function(indexArg:number,compareArray){ var typingsCounter:number = 0;
if((indexArg + 1) == compareArray.length){ var typingsCounterAdvance = function(){
typingsCounter++;
if(typeof config.typings[typingsCounter] != "undefined"){
installTypings();
} else {
plugins.beautylog.success("custom typings installed successfully"); plugins.beautylog.success("custom typings installed successfully");
typingsDone.resolve(); typingsDone.resolve();
} }
}; };
for (var key in config.typings) { var installTypings = function() {
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue); 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[key])}) plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
.then(function(){ .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 ------------------- * ----------- second compile TS -------------------
* ----------------------------------------------- */ * ----------------------------------------------- */

View File

@ -11,6 +11,7 @@ module NpmtsPlugins {
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mathjs: require("mathjs"),
mergeStream: require("merge2"), mergeStream: require("merge2"),
mocha: require("mocha"), mocha: require("mocha"),
path: require("path"), path: require("path"),