tscoverage/ts/npmts.config.ts

83 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2016-09-06 15:21:25 +00:00
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
2016-10-02 18:35:13 +00:00
2017-01-17 23:58:09 +00:00
import * as q from 'smartq'
2016-10-02 18:35:13 +00:00
2016-09-06 15:21:25 +00:00
export type npmtsMode = 'default' | 'custom'
2016-09-06 15:33:28 +00:00
export interface INpmtsConfig {
argv: any,
coverageTreshold: number,
mode: npmtsMode,
test: boolean,
testTs: any,
ts: any,
tsOptions: any,
watch: boolean
runData: {
coverageLcovInfo?: string,
coverageResult?: number
}
2016-09-06 15:21:25 +00:00
};
2016-08-19 07:46:36 +00:00
2017-01-17 23:58:09 +00:00
export let run = function (argvArg) {
let done = q.defer()
let defaultConfig: INpmtsConfig = {
argv: undefined,
coverageTreshold: 70,
mode: 'default',
test: true,
testTs: {},
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':
plugins.beautylog.ok('mode is ' + config.mode)
done.resolve(config)
break
default:
plugins.beautylog.error(`mode not recognised!`)
process.exit(1)
};
// handle default mode
if (config.mode === 'default') {
config.ts = {
'./ts/**/*.ts': './dist/'
}
config.testTs = {
'./test/**/*.ts': './test/'
}
};
// mix with commandline
if (config.argv.notest) {
config.test = false
};
if (config.argv.watch) {
config.watch = true
};
2016-03-29 23:32:41 +00:00
plugins.beautylog.ok('build options are ready!')
done.resolve(config)
return done.promise
2016-09-06 15:21:25 +00:00
}