introduce a merge option

This commit is contained in:
PhilKunz External
2017-06-15 23:42:48 +00:00
committed by Phil Kunz
parent f236d77952
commit 29dff4c0e3
5 changed files with 64 additions and 28 deletions

View File

@ -116,11 +116,21 @@ let checkNodeVersion = (configArg) => {
export let run = (configArg) => {
let done = q.defer()
plugins.beautylog.ora.text('Check Module: ...')
checkProjectTypings(configArg)
.then(checkDependencies)
.then(checkDevDependencies)
.then(checkNodeVersion)
.then(done.resolve)
.catch((err) => { console.log(err) })
// check cli
if (configArg.argv.nocheck) {
configArg.checkDependencies = false
}
if (configArg.checkDependencies) {
checkProjectTypings(configArg)
.then(checkDependencies)
.then(checkDevDependencies)
.then(checkNodeVersion)
.then(done.resolve)
.catch((err) => { console.log(err) })
} else {
done.resolve(configArg)
}
return done.promise
}

View File

@ -3,28 +3,36 @@ import paths = require('./npmts.paths')
import * as q from 'smartq'
export type npmtsMode = 'default' | 'custom'
/**
* 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'
export interface INpmtsConfig {
argv: any,
coverageTreshold: number,
mode: npmtsMode,
test: boolean,
testTs: any,
ts: any,
tsOptions: any,
argv: any
coverageTreshold: number
checkDependencies: boolean
mode: npmtsMode
test: boolean
testTs: any
ts: any
tsOptions: any
watch: boolean
runData: {
coverageLcovInfo?: string,
coverageLcovInfo?: string
coverageResult?: number
}
};
}
export let run = function (argvArg) {
let done = q.defer()
let defaultConfig: INpmtsConfig = {
argv: undefined,
coverageTreshold: 70,
checkDependencies: true,
mode: 'default',
test: true,
testTs: {},
@ -50,16 +58,17 @@ export let run = function (argvArg) {
switch (config.mode) {
case 'default':
case 'custom':
case 'merge':
plugins.beautylog.ok('mode is ' + config.mode)
done.resolve(config)
break
default:
plugins.beautylog.error(`mode not recognised!`)
plugins.beautylog.error(`mode not recognised! Can be default or custom`)
process.exit(1)
};
// handle default mode
if (config.mode === 'default') {
if (config.mode === 'default' || config.mode === 'merge') {
config.ts = {
'./ts/**/*.ts': './dist/'
}