tscoverage/dist/npmts.config.js

72 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2016-03-12 09:21:16 +00:00
"use strict";
2017-02-27 21:19:14 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2016-09-22 21:23:16 +00:00
const plugins = require("./npmts.plugins");
const paths = require("./npmts.paths");
2017-08-29 14:15:24 +00:00
const smartq = require("smartq");
2016-08-19 07:46:36 +00:00
exports.run = function (argvArg) {
2017-08-29 14:15:24 +00:00
let done = smartq.defer();
2016-09-22 21:23:16 +00:00
let defaultConfig = {
2016-08-19 07:46:36 +00:00
argv: undefined,
coverageTreshold: 70,
2017-06-15 23:42:48 +00:00
checkDependencies: true,
2016-09-06 15:21:25 +00:00
mode: 'default',
2016-08-19 07:46:36 +00:00
test: true,
testTs: {},
testConfig: {
2017-07-27 23:21:37 +00:00
parallel: true,
coverage: true
},
2016-08-19 07:46:36 +00:00
ts: {},
2016-09-22 21:23:16 +00:00
tsOptions: {},
watch: false,
runData: {}
2016-08-19 07:46:36 +00:00
};
// mix with configfile
2017-01-21 22:23:00 +00:00
plugins.beautylog.ora.text('running npmextra');
2016-09-24 14:57:30 +00:00
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
let config = localNpmextra.dataFor('npmts', defaultConfig);
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':
2017-06-15 23:42:48 +00:00
case 'merge':
2016-09-06 15:21:25 +00:00
plugins.beautylog.ok('mode is ' + config.mode);
2016-08-19 07:46:36 +00:00
done.resolve(config);
break;
default:
2017-06-15 23:42:48 +00:00
plugins.beautylog.error(`mode not recognised! Can be default or custom`);
2016-08-19 07:46:36 +00:00
process.exit(1);
}
2016-09-06 15:21:25 +00:00
// handle default mode
2017-06-15 23:42:48 +00:00
if (config.mode === 'default' || config.mode === 'merge') {
2016-09-22 21:23:16 +00:00
config.ts = {
2016-09-29 14:19:49 +00:00
'./ts/**/*.ts': './dist/'
2016-09-22 21:23:16 +00:00
};
config.testTs = {
2016-09-29 14:19:49 +00:00
'./test/**/*.ts': './test/'
2016-09-22 21:23:16 +00:00
};
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.nocoverage) {
2017-07-27 23:21:37 +00:00
config.testConfig.coverage = false;
}
if (config.argv.nochecks) {
config.checkDependencies = 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);
2017-08-29 14:15:24 +00:00
configDeferred.resolve(config);
2016-02-19 23:53:23 +00:00
return done.promise;
};
2017-08-29 14:15:24 +00:00
// config deferred usage
let configDeferred = smartq.defer();
exports.configPromise = configDeferred.promise;