tscoverage/ts/npmts.options.ts

81 lines
1.8 KiB
TypeScript
Raw Normal View History

2016-05-25 03:23:48 +00:00
import "typings-global";
2016-02-19 23:53:23 +00:00
import plugins = require("./npmts.plugins");
2016-08-19 07:46:36 +00:00
import paths = require("./npmts.paths");
2016-05-17 00:32:40 +00:00
import {npmtsOra} from "./npmts.promisechain";
2016-08-19 07:46:36 +00:00
export type npmtsMode = "default" | "custom"
2016-08-19 07:46:36 +00:00
export interface npmtsConfig {
argv:any,
coverageTreshold:number,
docs:boolean,
mode: npmtsMode,
test:boolean,
testTs:any,
ts:any,
tsOptions:any
};
export var run = function(argvArg){
let done = plugins.Q.defer();
let defaultConfig:npmtsConfig = {
argv:undefined,
coverageTreshold: 70,
docs: true,
mode:"default",
test:true,
testTs:{},
ts:{},
tsOptions: {}
};
// mix with configfile
npmtsOra.text("looking for npmextra.json");
let config:npmtsConfig = plugins.npmextra.dataFor({
toolName:"npmts",
defaultSettings:defaultConfig,
cwd:paths.cwd
});
2016-08-19 09:16:13 +00:00
// add argv
config.argv = argvArg;
2016-08-19 07:46:36 +00:00
// check mode
switch (config.mode){
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode);
done.resolve(config);
break;
default:
2016-08-19 09:16:13 +00:00
plugins.beautylog.error(`mode not recognised!`);
2016-08-19 07:46:36 +00:00
process.exit(1);
};
//handle default mode
2016-02-19 23:53:23 +00:00
if (config.mode == "default"){
config.ts = {
2016-06-07 06:49:22 +00:00
["./ts/**/*.ts"]: "./dist/"
};
config.testTs = {
2016-02-19 23:53:23 +00:00
["./test/test.ts"]: "./test/"
};
2016-08-19 07:46:36 +00:00
};
2016-03-23 14:47:28 +00:00
2016-08-19 07:46:36 +00:00
// mix with commandline
if(config.argv.notest){
config.test = false;
};
if(config.argv.nodocs){
config.docs = false;
};
2016-03-29 23:32:41 +00:00
2016-04-01 23:20:52 +00:00
plugins.beautylog.ok("build options are ready!");
done.resolve(config);
2016-02-19 23:53:23 +00:00
return done.promise;
};