Merge branch 'master' into 'master'

introduce a merge option

See merge request !5
This commit is contained in:
Phil Kunz 2017-06-15 23:42:52 +00:00
commit 2bd187b704
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: ...');
// check cli
if (configArg.argv.nocheck) {
configArg.checkDependencies = false;
}
if (configArg.checkDependencies) {
checkProjectTypings(configArg) checkProjectTypings(configArg)
.then(checkDependencies) .then(checkDependencies)
.then(checkDevDependencies) .then(checkDevDependencies)
.then(checkNodeVersion) .then(checkNodeVersion)
.then(done.resolve) .then(done.resolve)
.catch((err) => { console.log(err); }); .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: ...')
// check cli
if (configArg.argv.nocheck) {
configArg.checkDependencies = false
}
if (configArg.checkDependencies) {
checkProjectTypings(configArg) checkProjectTypings(configArg)
.then(checkDependencies) .then(checkDependencies)
.then(checkDevDependencies) .then(checkDevDependencies)
.then(checkNodeVersion) .then(checkNodeVersion)
.then(done.resolve) .then(done.resolve)
.catch((err) => { console.log(err) }) .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/'
} }