2016-09-06 15:21:25 +00:00
|
|
|
import 'typings-global'
|
|
|
|
import plugins = require('./npmts.plugins')
|
|
|
|
import paths = require('./npmts.paths')
|
|
|
|
import { npmtsOra } from './npmts.promisechain'
|
2016-03-23 13:12:58 +00:00
|
|
|
|
2016-09-06 15:21:25 +00:00
|
|
|
export type npmtsMode = 'default' | 'custom'
|
2016-03-23 13:12:58 +00:00
|
|
|
|
2016-09-06 15:33:28 +00:00
|
|
|
export interface INpmtsConfig {
|
2016-09-06 15:21:25 +00:00
|
|
|
argv: any,
|
|
|
|
coverageTreshold: number,
|
|
|
|
docs: boolean,
|
|
|
|
mode: npmtsMode,
|
|
|
|
test: boolean,
|
|
|
|
testTs: any,
|
|
|
|
ts: any,
|
2016-09-22 21:23:16 +00:00
|
|
|
tsOptions: any,
|
|
|
|
watch: boolean
|
2016-08-19 07:46:36 +00:00
|
|
|
|
2016-09-06 15:21:25 +00:00
|
|
|
};
|
2016-08-19 07:46:36 +00:00
|
|
|
|
2016-09-06 15:21:25 +00:00
|
|
|
export var run = function (argvArg) {
|
2016-09-22 21:23:16 +00:00
|
|
|
let done = plugins.q.defer()
|
2016-09-06 15:33:28 +00:00
|
|
|
let defaultConfig: INpmtsConfig = {
|
2016-09-06 15:21:25 +00:00
|
|
|
argv: undefined,
|
2016-08-19 07:46:36 +00:00
|
|
|
coverageTreshold: 70,
|
|
|
|
docs: true,
|
2016-09-06 15:21:25 +00:00
|
|
|
mode: 'default',
|
|
|
|
test: true,
|
|
|
|
testTs: {},
|
|
|
|
ts: {},
|
2016-09-22 21:23:16 +00:00
|
|
|
tsOptions: {},
|
|
|
|
watch: false
|
2016-09-06 15:21:25 +00:00
|
|
|
}
|
2016-08-19 07:46:36 +00:00
|
|
|
|
|
|
|
// mix with configfile
|
2016-09-06 15:21:25 +00:00
|
|
|
npmtsOra.text('looking for npmextra.json')
|
2016-09-18 11:08:31 +00:00
|
|
|
let config: INpmtsConfig = plugins.npmextra.dataFor<INpmtsConfig>({
|
2016-09-06 15:21:25 +00:00
|
|
|
toolName: 'npmts',
|
|
|
|
defaultSettings: defaultConfig,
|
|
|
|
cwd: paths.cwd
|
|
|
|
})
|
2016-08-19 07:46:36 +00:00
|
|
|
|
2016-08-19 09:16:13 +00:00
|
|
|
// add argv
|
2016-09-06 15:21:25 +00:00
|
|
|
config.argv = argvArg
|
2016-08-19 09:16:13 +00:00
|
|
|
|
2016-08-19 07:46:36 +00:00
|
|
|
// check mode
|
2016-09-06 15:21:25 +00:00
|
|
|
switch (config.mode) {
|
|
|
|
case 'default':
|
|
|
|
case 'custom':
|
|
|
|
plugins.beautylog.ok('mode is ' + config.mode)
|
|
|
|
done.resolve(config)
|
|
|
|
break
|
2016-08-19 07:46:36 +00:00
|
|
|
default:
|
2016-09-06 15:21:25 +00:00
|
|
|
plugins.beautylog.error(`mode not recognised!`)
|
|
|
|
process.exit(1)
|
2016-08-19 07:46:36 +00:00
|
|
|
};
|
2016-03-23 13:12:58 +00:00
|
|
|
|
2016-09-06 15:21:25 +00:00
|
|
|
// handle default mode
|
|
|
|
if (config.mode === 'default') {
|
2016-02-19 23:53:23 +00:00
|
|
|
config.ts = {
|
2016-09-06 15:21:25 +00:00
|
|
|
['./ts/**/*.ts']: './dist/'
|
|
|
|
}
|
2016-06-07 06:49:22 +00:00
|
|
|
config.testTs = {
|
2016-09-06 15:21:25 +00:00
|
|
|
['./test/test.ts']: './test/'
|
|
|
|
}
|
2016-08-19 07:46:36 +00:00
|
|
|
};
|
2016-03-23 13:12:58 +00:00
|
|
|
|
2016-08-19 07:46:36 +00:00
|
|
|
// mix with commandline
|
2016-09-06 15:21:25 +00:00
|
|
|
if (config.argv.notest) {
|
|
|
|
config.test = false
|
2016-08-19 07:46:36 +00:00
|
|
|
};
|
2016-09-06 15:21:25 +00:00
|
|
|
if (config.argv.nodocs) {
|
|
|
|
config.docs = false
|
2016-08-19 07:46:36 +00:00
|
|
|
};
|
2016-09-22 21:23:16 +00:00
|
|
|
if (config.argv.watch) {
|
|
|
|
config.watch = true
|
|
|
|
};
|
2016-03-29 23:32:41 +00:00
|
|
|
|
2016-09-06 15:21:25 +00:00
|
|
|
plugins.beautylog.ok('build options are ready!')
|
|
|
|
done.resolve(config)
|
|
|
|
return done.promise
|
|
|
|
}
|