tscoverage/ts/npmts.config.ts

109 lines
2.2 KiB
TypeScript
Raw 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
2017-07-27 23:21:37 +00:00
// interfaces
import { ITapbufferConfig } from 'tapbuffer'
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 {
2017-06-15 23:42:48 +00:00
argv: any
coverageTreshold: number
checkDependencies: boolean
mode: npmtsMode
test: boolean
testTs: any
2017-07-27 23:21:37 +00:00
testConfig: ITapbufferConfig
2017-06-15 23:42:48 +00:00
ts: any
tsOptions: any
watch: boolean
runData: {
2017-06-15 23:42:48 +00:00
coverageLcovInfo?: string
coverageResult?: number
}
2017-06-15 23:42:48 +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,
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:
2017-06-15 23:42:48 +00:00
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) {
2017-07-27 23:21:37 +00:00
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)
return done.promise
2016-09-06 15:21:25 +00:00
}