tscoverage/ts/npmts.config.ts

111 lines
2.4 KiB
TypeScript
Raw Permalink Normal View History

import plugins = require('./npmts.plugins');
import paths = require('./npmts.paths');
2016-10-02 18:35:13 +00:00
import * as smartq from 'smartq';
2016-10-02 18:35:13 +00:00
2017-07-27 23:21:37 +00:00
// interfaces
import { ITapbufferConfig } from 'tapbuffer';
2017-07-27 23:21:37 +00:00
2017-06-15 23:42:48 +00:00
/**
* specifies the different modes available
* default -> uses default options no matterm what
* merge -> uses merged default + custom options
* custom -> only uses specified options
*/
export type npmtsMode = 'default' | 'custom' | 'merge';
2016-09-06 15:33:28 +00:00
export interface INpmtsConfig {
argv: any;
coverageTreshold: number;
checkDependencies: boolean;
mode: npmtsMode;
test: boolean;
testTs: any;
testConfig: ITapbufferConfig;
ts: any;
tsOptions: any;
watch: boolean;
runData: {
coverageLcovInfo?: string;
coverageResult?: number;
};
2017-06-15 23:42:48 +00:00
}
2016-08-19 07:46:36 +00:00
export let run = function(argvArg) {
let done = smartq.defer();
let defaultConfig: INpmtsConfig = {
argv: undefined,
coverageTreshold: 70,
2017-06-15 23:42:48 +00:00
checkDependencies: true,
mode: 'default',
test: true,
testTs: {},
testConfig: {
2017-07-27 23:21:37 +00:00
parallel: true,
coverage: true
},
ts: {},
tsOptions: {},
watch: false,
runData: {}
};
2016-08-19 07:46:36 +00:00
// mix with configfile
plugins.beautylog.ora.text('running npmextra');
2016-09-24 14:57:30 +00:00
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
let config: INpmtsConfig = localNpmextra.dataFor<INpmtsConfig>('npmts', defaultConfig);
2016-08-19 07:46:36 +00:00
// add argv
config.argv = argvArg;
2016-08-19 09:16:13 +00:00
// check mode
switch (config.mode) {
case 'default':
case 'custom':
2017-06-15 23:42:48 +00:00
case 'merge':
plugins.beautylog.ok('mode is ' + config.mode);
done.resolve(config);
break;
default:
plugins.beautylog.error(`mode not recognised! Can be default or custom`);
process.exit(1);
2017-06-16 14:08:36 +00:00
}
// handle default mode
2017-06-15 23:42:48 +00:00
if (config.mode === 'default' || config.mode === 'merge') {
config.ts = {
'./ts/**/*.ts': './dist/'
};
config.testTs = {
'./test/**/*.ts': './test/'
};
2017-06-16 14:08:36 +00:00
}
// mix with commandline
if (config.argv.notest) {
config.test = false;
2017-06-16 14:08:36 +00:00
}
if (config.argv.nocoverage) {
config.testConfig.coverage = false;
}
if (config.argv.nochecks) {
config.checkDependencies = false;
}
if (config.argv.watch) {
config.watch = true;
2017-06-16 14:08:36 +00:00
}
2016-03-29 23:32:41 +00:00
plugins.beautylog.ok('build options are ready!');
done.resolve(config);
configDeferred.resolve(config);
return done.promise;
};
2017-08-29 14:15:24 +00:00
// config deferred usage
let configDeferred = smartq.defer<INpmtsConfig>();
export let configPromise = configDeferred.promise;