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

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

View File

@ -1,7 +1,14 @@
export declare 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 declare type npmtsMode = 'default' | 'custom' | 'merge';
export interface INpmtsConfig { export interface INpmtsConfig {
argv: any; argv: any;
coverageTreshold: number; coverageTreshold: number;
checkDependencies: boolean;
mode: npmtsMode; mode: npmtsMode;
test: boolean; test: boolean;
testTs: any; testTs: any;

View File

@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmts.plugins"); const plugins = require("./npmts.plugins");
const paths = require("./npmts.paths"); const paths = require("./npmts.paths");
const q = require("smartq"); const q = require("smartq");
;
exports.run = function (argvArg) { exports.run = function (argvArg) {
let done = q.defer(); let done = q.defer();
let defaultConfig = { let defaultConfig = {
argv: undefined, argv: undefined,
coverageTreshold: 70, coverageTreshold: 70,
checkDependencies: true,
mode: 'default', mode: 'default',
test: true, test: true,
testTs: {}, testTs: {},
@ -27,16 +27,17 @@ exports.run = function (argvArg) {
switch (config.mode) { switch (config.mode) {
case 'default': case 'default':
case 'custom': case 'custom':
case 'merge':
plugins.beautylog.ok('mode is ' + config.mode); plugins.beautylog.ok('mode is ' + config.mode);
done.resolve(config); done.resolve(config);
break; break;
default: default:
plugins.beautylog.error(`mode not recognised!`); plugins.beautylog.error(`mode not recognised! Can be default or custom`);
process.exit(1); process.exit(1);
} }
; ;
// handle default mode // handle default mode
if (config.mode === 'default') { if (config.mode === 'default' || config.mode === 'merge') {
config.ts = { config.ts = {
'./ts/**/*.ts': './dist/' './ts/**/*.ts': './dist/'
}; };

View File

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

View File

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