tscoverage/dist/npmts.options.js

68 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-03-12 09:21:16 +00:00
"use strict";
require("typings-global");
2016-09-22 21:23:16 +00:00
const plugins = require("./npmts.plugins");
const paths = require("./npmts.paths");
const npmts_promisechain_1 = require("./npmts.promisechain");
2016-08-19 07:46:36 +00:00
;
exports.run = function (argvArg) {
2016-09-22 21:23:16 +00:00
let done = plugins.q.defer();
let defaultConfig = {
2016-08-19 07:46:36 +00:00
argv: undefined,
coverageTreshold: 70,
docs: true,
2016-09-06 15:21:25 +00:00
mode: 'default',
2016-08-19 07:46:36 +00:00
test: true,
testTs: {},
ts: {},
2016-09-22 21:23:16 +00:00
tsOptions: {},
watch: false
2016-08-19 07:46:36 +00:00
};
// mix with configfile
2016-09-06 15:21:25 +00:00
npmts_promisechain_1.npmtsOra.text('looking for npmextra.json');
2016-09-22 21:23:16 +00:00
let config = plugins.npmextra.dataFor({
2016-09-06 15:21:25 +00:00
toolName: 'npmts',
2016-08-19 07:46:36 +00:00
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) {
2016-09-06 15:21:25 +00:00
case 'default':
case 'custom':
plugins.beautylog.ok('mode is ' + config.mode);
2016-08-19 07:46:36 +00:00
done.resolve(config);
break;
default:
2016-09-22 21:23:16 +00:00
plugins.beautylog.error(`mode not recognised!`);
2016-08-19 07:46:36 +00:00
process.exit(1);
}
;
2016-09-06 15:21:25 +00:00
// handle default mode
if (config.mode === 'default') {
2016-09-22 21:23:16 +00:00
config.ts = {
['./ts/**/*.ts']: './dist/'
};
config.testTs = {
['./test/test.ts']: './test/'
};
2016-02-19 23:53:23 +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-09-22 21:23:16 +00:00
if (config.argv.watch) {
config.watch = true;
}
;
2016-09-06 15:21:25 +00:00
plugins.beautylog.ok('build options are ready!');
done.resolve(config);
2016-02-19 23:53:23 +00:00
return done.promise;
};