now accepts config file
This commit is contained in:
parent
7d18e92ff1
commit
de4bbaed9f
19
README.md
19
README.md
@ -37,8 +37,23 @@ the TypeScript Compiler will use the declaration file to resolve typings.
|
|||||||
|
|
||||||
|
|
||||||
### Custom behaviour
|
### Custom behaviour
|
||||||
We are currently building support for custom behaviour with a super simple config file.
|
NPMTS looks for an npmts.json at the root of your package.
|
||||||
Check back soon.
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mode":"custom",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/custom.ts":"./customcompiled.js"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./customdir"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* **mode** can be "default" or "custom"
|
||||||
|
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
||||||
|
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
||||||
|
|
||||||
## Readme for Devs
|
## Readme for Devs
|
||||||
There is a [README-dev.md](README-dev.md) in the repo.
|
There is a [README-dev.md](README-dev.md) in the repo.
|
||||||
|
5
index.d.ts
vendored
5
index.d.ts
vendored
@ -14,6 +14,7 @@ declare module NpmtsPlugins {
|
|||||||
path: any;
|
path: any;
|
||||||
q: any;
|
q: any;
|
||||||
smartcli: any;
|
smartcli: any;
|
||||||
|
smartfile: any;
|
||||||
typings: any;
|
typings: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -21,9 +22,10 @@ declare module NpmtsPaths {
|
|||||||
var init: () => any;
|
var init: () => any;
|
||||||
}
|
}
|
||||||
declare module NpmtsOptions {
|
declare module NpmtsOptions {
|
||||||
|
var config: any;
|
||||||
var run: () => any;
|
var run: () => any;
|
||||||
}
|
}
|
||||||
declare module NpmtsTypings {
|
declare module NpmtsCustom {
|
||||||
var run: () => any;
|
var run: () => any;
|
||||||
}
|
}
|
||||||
declare module NpmtsDefault {
|
declare module NpmtsDefault {
|
||||||
@ -49,6 +51,7 @@ declare var plugins: {
|
|||||||
path: any;
|
path: any;
|
||||||
q: any;
|
q: any;
|
||||||
smartcli: any;
|
smartcli: any;
|
||||||
|
smartfile: any;
|
||||||
typings: any;
|
typings: any;
|
||||||
};
|
};
|
||||||
declare var paths: any;
|
declare var paths: any;
|
||||||
|
106
index.js
106
index.js
@ -18,6 +18,7 @@ var NpmtsPlugins;
|
|||||||
path: require("path"),
|
path: require("path"),
|
||||||
q: require("q"),
|
q: require("q"),
|
||||||
smartcli: require("smartcli"),
|
smartcli: require("smartcli"),
|
||||||
|
smartfile: require("smartfile"),
|
||||||
typings: require("typings")
|
typings: require("typings")
|
||||||
};
|
};
|
||||||
return plugins;
|
return plugins;
|
||||||
@ -40,36 +41,110 @@ var NpmtsPaths;
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
var NpmtsOptions;
|
var NpmtsOptions;
|
||||||
(function (NpmtsOptions) {
|
(function (NpmtsOptions) {
|
||||||
|
NpmtsOptions.config = {};
|
||||||
NpmtsOptions.run = function () {
|
NpmtsOptions.run = function () {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
done.resolve(); //TODO: check for options
|
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
||||||
|
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
NpmtsOptions.config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (NpmtsOptions.config.mode) {
|
||||||
|
case "default":
|
||||||
|
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + NpmtsOptions.config.mode.yellow + " not recognised!".red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
NpmtsOptions.config.mode = "default";
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
;
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
})(NpmtsOptions || (NpmtsOptions = {}));
|
})(NpmtsOptions || (NpmtsOptions = {}));
|
||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
var NpmtsTypings;
|
var NpmtsCustom;
|
||||||
(function (NpmtsTypings) {
|
(function (NpmtsCustom) {
|
||||||
NpmtsTypings.run = function () {
|
NpmtsCustom.run = function () {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
plugins.beautylog.log("now installing typings");
|
var config = NpmtsOptions.config;
|
||||||
plugins.typings.install({ production: false, cwd: paths.tsDir })
|
if (config.mode === "custom") {
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.mergeStream({ end: false });
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.q.defer();
|
||||||
|
var checkTypingsDone = function (indexArg, compareArray) {
|
||||||
|
if ((indexArg + 1) == compareArray.length) {
|
||||||
|
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]) })
|
||||||
.then(function () {
|
.then(function () {
|
||||||
|
checkTypingsDone(key, config.typings);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function () {
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: plugins.path.basename(config.ts[key]),
|
||||||
|
declaration: true
|
||||||
|
}));
|
||||||
|
var stream = plugins.mergeStream([
|
||||||
|
tsStream.dts.pipe(plugins.gulp.dest(paths.cwd)),
|
||||||
|
tsStream.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]))))
|
||||||
|
]);
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
})(NpmtsTypings || (NpmtsTypings = {}));
|
})(NpmtsCustom || (NpmtsCustom = {}));
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
var NpmtsDefault;
|
var NpmtsDefault;
|
||||||
(function (NpmtsDefault) {
|
(function (NpmtsDefault) {
|
||||||
NpmtsDefault.run = function () {
|
NpmtsDefault.run = function () {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
|
plugins.gulp.task("defaultTypings", function (cb) {
|
||||||
|
plugins.beautylog.log("now installing default typings");
|
||||||
|
plugins.typings.install({ production: false, cwd: paths.tsDir })
|
||||||
|
.then(function () {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
plugins.gulp.task("defaultIndexTS", function () {
|
plugins.gulp.task("defaultIndexTS", function () {
|
||||||
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
||||||
var tsResult = plugins.gulp.src(paths.indexTS)
|
var tsResult = plugins.gulp.src(paths.indexTS)
|
||||||
.pipe(plugins.g.typescript({
|
.pipe(plugins.g.typescript({
|
||||||
out: "index.js",
|
out: "./index.js",
|
||||||
declaration: true
|
declaration: true
|
||||||
}));
|
}));
|
||||||
return plugins.mergeStream([
|
return plugins.mergeStream([
|
||||||
@ -89,12 +164,18 @@ var NpmtsDefault;
|
|||||||
return stream;
|
return stream;
|
||||||
});
|
});
|
||||||
plugins.gulp.task("defaultCleanup", function (cb) {
|
plugins.gulp.task("defaultCleanup", function (cb) {
|
||||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
plugins.gulp.task("default", function (cb) {
|
plugins.gulp.task("default", function (cb) {
|
||||||
plugins.g.sequence("defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
|
if (NpmtsOptions.config.mode == "default") {
|
||||||
|
plugins.g.sequence("defaultTypings", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cb();
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
@ -123,8 +204,8 @@ var NpmtsPromisechain;
|
|||||||
NpmtsPromisechain.init = function () {
|
NpmtsPromisechain.init = function () {
|
||||||
var promisechain;
|
var promisechain;
|
||||||
NpmtsOptions.run()
|
NpmtsOptions.run()
|
||||||
.then(NpmtsTypings.run)
|
|
||||||
.then(NpmtsDefault.run)
|
.then(NpmtsDefault.run)
|
||||||
|
.then(NpmtsCustom.run)
|
||||||
.then(NpmtsTests.run);
|
.then(NpmtsTests.run);
|
||||||
return promisechain;
|
return promisechain;
|
||||||
};
|
};
|
||||||
@ -134,7 +215,6 @@ var NpmtsPromisechain;
|
|||||||
/// <reference path="./npmts.cli.ts" />
|
/// <reference path="./npmts.cli.ts" />
|
||||||
/// <reference path="./npmts.paths.ts" />
|
/// <reference path="./npmts.paths.ts" />
|
||||||
/// <reference path="./npmts.options.ts" />
|
/// <reference path="./npmts.options.ts" />
|
||||||
/// <reference path="./npmts.typings.ts" />
|
|
||||||
/// <reference path="./npmts.custom.ts" />
|
/// <reference path="./npmts.custom.ts" />
|
||||||
/// <reference path="./npmts.default.ts" />
|
/// <reference path="./npmts.default.ts" />
|
||||||
/// <reference path="./npmts.tests.ts" />
|
/// <reference path="./npmts.tests.ts" />
|
||||||
|
@ -27,17 +27,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.6",
|
"beautylog": "2.0.7",
|
||||||
"fs-extra": "^0.26.5",
|
"fs-extra": "^0.26.5",
|
||||||
"gulp": "3.9.0",
|
"gulp": "3.9.0",
|
||||||
"gulp-insert": "0.5.0",
|
"gulp-insert": "0.5.0",
|
||||||
"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",
|
||||||
"merge2": "1.0.0",
|
"merge2": "1.0.1",
|
||||||
"mocha": "^2.4.5",
|
"mocha": "^2.4.5",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"smartcli": "0.0.11",
|
"smartcli": "0.0.11",
|
||||||
"typings": "^0.6.5"
|
"smartfile": "0.0.11",
|
||||||
|
"typings": "^0.6.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
test/assets/customcompiled.d.ts
vendored
Normal file
1
test/assets/customcompiled.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare var hello: string;
|
3
test/assets/customcompiled.js
Normal file
3
test/assets/customcompiled.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var hello = "hello";
|
2
test/assets/customdir/custom.js
Normal file
2
test/assets/customdir/custom.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var hello = "hello";
|
||||||
|
//# sourceMappingURL=custom.js.map
|
1
test/assets/customdir/custom.js.map
Normal file
1
test/assets/customdir/custom.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}
|
1
test/assets/customdir/custom.ts
Normal file
1
test/assets/customdir/custom.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var hello = "hello";
|
7
test/assets/customdir/typings.json
Normal file
7
test/assets/customdir/typings.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
9
test/assets/npmts.json
Normal file
9
test/assets/npmts.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"mode":"custom",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/custom.ts":"./customcompiled.js"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./customdir"
|
||||||
|
]
|
||||||
|
}
|
@ -3,7 +3,6 @@
|
|||||||
/// <reference path="./npmts.cli.ts" />
|
/// <reference path="./npmts.cli.ts" />
|
||||||
/// <reference path="./npmts.paths.ts" />
|
/// <reference path="./npmts.paths.ts" />
|
||||||
/// <reference path="./npmts.options.ts" />
|
/// <reference path="./npmts.options.ts" />
|
||||||
/// <reference path="./npmts.typings.ts" />
|
|
||||||
/// <reference path="./npmts.custom.ts" />
|
/// <reference path="./npmts.custom.ts" />
|
||||||
/// <reference path="./npmts.default.ts" />
|
/// <reference path="./npmts.default.ts" />
|
||||||
/// <reference path="./npmts.tests.ts" />
|
/// <reference path="./npmts.tests.ts" />
|
||||||
|
@ -1 +1,60 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsCustom {
|
||||||
|
export var run = function(){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = NpmtsOptions.config;
|
||||||
|
if(config.mode === "custom"){
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.mergeStream({end: false});
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.q.defer();
|
||||||
|
var checkTypingsDone = function(indexArg:number,compareArray){
|
||||||
|
if((indexArg + 1) == compareArray.length){
|
||||||
|
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])})
|
||||||
|
.then(function(){
|
||||||
|
checkTypingsDone(key,config.typings);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function(){
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: plugins.path.basename(config.ts[key]),
|
||||||
|
declaration: true
|
||||||
|
}));
|
||||||
|
var stream = plugins.mergeStream([
|
||||||
|
tsStream.dts.pipe(plugins.gulp.dest(paths.cwd)),
|
||||||
|
tsStream.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(
|
||||||
|
plugins.path.dirname(
|
||||||
|
plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
)
|
||||||
|
))
|
||||||
|
]);
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain",function(){
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish",function(){
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
}
|
@ -3,13 +3,18 @@
|
|||||||
module NpmtsDefault {
|
module NpmtsDefault {
|
||||||
export var run = function() {
|
export var run = function() {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
|
plugins.gulp.task("defaultTypings",function(cb){
|
||||||
|
plugins.beautylog.log("now installing default typings");
|
||||||
|
plugins.typings.install({production: false, cwd: paths.tsDir})
|
||||||
|
.then(function(){
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
plugins.gulp.task("defaultIndexTS", function(){
|
plugins.gulp.task("defaultIndexTS", function(){
|
||||||
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
||||||
var tsResult = plugins.gulp.src(paths.indexTS)
|
var tsResult = plugins.gulp.src(paths.indexTS)
|
||||||
.pipe(plugins.g.typescript({
|
.pipe(plugins.g.typescript({
|
||||||
out:"index.js",
|
out:"./index.js",
|
||||||
declaration:true
|
declaration:true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -32,13 +37,19 @@ module NpmtsDefault {
|
|||||||
});
|
});
|
||||||
|
|
||||||
plugins.gulp.task("defaultCleanup",function(cb){
|
plugins.gulp.task("defaultCleanup",function(cb){
|
||||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
plugins.gulp.task("default",function(cb){
|
plugins.gulp.task("default",function(cb){
|
||||||
plugins.g.sequence("defaultIndexTS","defaultTestTS","defaultCleanup",cb);
|
if(NpmtsOptions.config.mode == "default"){
|
||||||
|
plugins.g.sequence("defaultTypings","defaultIndexTS","defaultTestTS","defaultCleanup",cb);
|
||||||
|
} else {
|
||||||
|
cb();
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
|
@ -1,8 +1,29 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
module NpmtsOptions {
|
module NpmtsOptions {
|
||||||
|
export var config:any = {};
|
||||||
export var run = function(){
|
export var run = function(){
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
done.resolve(); //TODO: check for options
|
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
||||||
|
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (config.mode){
|
||||||
|
case "default":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
config.mode = "default";
|
||||||
|
done.resolve();
|
||||||
|
};
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,7 @@ module NpmtsPlugins {
|
|||||||
path: require("path"),
|
path: require("path"),
|
||||||
q:require("q"),
|
q:require("q"),
|
||||||
smartcli: require("smartcli"),
|
smartcli: require("smartcli"),
|
||||||
|
smartfile: require("smartfile"),
|
||||||
typings: require("typings")
|
typings: require("typings")
|
||||||
};
|
};
|
||||||
return plugins;
|
return plugins;
|
||||||
|
@ -3,8 +3,8 @@ module NpmtsPromisechain {
|
|||||||
export var init = function(){
|
export var init = function(){
|
||||||
var promisechain;
|
var promisechain;
|
||||||
NpmtsOptions.run()
|
NpmtsOptions.run()
|
||||||
.then(NpmtsTypings.run)
|
|
||||||
.then(NpmtsDefault.run)
|
.then(NpmtsDefault.run)
|
||||||
|
.then(NpmtsCustom.run)
|
||||||
.then(NpmtsTests.run);
|
.then(NpmtsTests.run);
|
||||||
return promisechain;
|
return promisechain;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module NpmtsTypings {
|
|
||||||
export var run = function(){
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
plugins.beautylog.log("now installing typings");
|
|
||||||
plugins.typings.install({production: false, cwd: paths.tsDir})
|
|
||||||
.then(function(){
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user