add coverage option

This commit is contained in:
Philipp Kunz 2017-06-16 16:08:36 +02:00
parent 2bd187b704
commit 455c89d68d
5 changed files with 33 additions and 18 deletions

18
dist/mod02/index.js vendored
View File

@ -109,11 +109,19 @@ exports.run = function (configArg) {
plugins.beautylog.ora.text('now starting tests'); plugins.beautylog.ora.text('now starting tests');
plugins.beautylog.ora.end(); plugins.beautylog.ora.end();
plugins.beautylog.log('ready for tapbuffer:'); plugins.beautylog.log('ready for tapbuffer:');
tap(config) if (configArg.coverage) {
.then(handleCoverageData) tap(config)
.then(() => { .then(handleCoverageData)
done.resolve(config); .then(() => {
}).catch(err => { console.log(err); }); done.resolve(config);
}).catch(err => { console.log(err); });
}
else {
tap(config)
.then(() => {
done.resolve(config);
}).catch(err => { console.log(err); });
}
} }
else { else {
plugins.beautylog.ora.end(); plugins.beautylog.ora.end();

View File

@ -7,6 +7,7 @@
export declare type npmtsMode = 'default' | 'custom' | 'merge'; export declare type npmtsMode = 'default' | 'custom' | 'merge';
export interface INpmtsConfig { export interface INpmtsConfig {
argv: any; argv: any;
coverage: boolean;
coverageTreshold: number; coverageTreshold: number;
checkDependencies: boolean; checkDependencies: boolean;
mode: npmtsMode; mode: npmtsMode;

View File

@ -7,6 +7,7 @@ exports.run = function (argvArg) {
let done = q.defer(); let done = q.defer();
let defaultConfig = { let defaultConfig = {
argv: undefined, argv: undefined,
coverage: true,
coverageTreshold: 70, coverageTreshold: 70,
checkDependencies: true, checkDependencies: true,
mode: 'default', mode: 'default',
@ -35,7 +36,6 @@ exports.run = function (argvArg) {
plugins.beautylog.error(`mode not recognised! Can be default or custom`); 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' || config.mode === 'merge') { if (config.mode === 'default' || config.mode === 'merge') {
config.ts = { config.ts = {
@ -45,16 +45,13 @@ exports.run = function (argvArg) {
'./test/**/*.ts': './test/' './test/**/*.ts': './test/'
}; };
} }
;
// mix with commandline // mix with commandline
if (config.argv.notest) { if (config.argv.notest) {
config.test = false; config.test = false;
} }
;
if (config.argv.watch) { if (config.argv.watch) {
config.watch = true; config.watch = true;
} }
;
plugins.beautylog.ok('build options are ready!'); plugins.beautylog.ok('build options are ready!');
done.resolve(config); done.resolve(config);
return done.promise; return done.promise;

View File

@ -114,12 +114,19 @@ export let run = function (configArg: INpmtsConfig) {
plugins.beautylog.ora.text('now starting tests') plugins.beautylog.ora.text('now starting tests')
plugins.beautylog.ora.end() plugins.beautylog.ora.end()
plugins.beautylog.log('ready for tapbuffer:') plugins.beautylog.log('ready for tapbuffer:')
if (configArg.coverage) {
tap(config)
.then(handleCoverageData)
.then(() => {
done.resolve(config)
}).catch(err => { console.log(err) })
} else {
tap(config)
.then(() => {
done.resolve(config)
}).catch(err => { console.log(err) })
}
tap(config)
.then(handleCoverageData)
.then(() => {
done.resolve(config)
}).catch(err => { console.log(err) })
} else { } else {
plugins.beautylog.ora.end() plugins.beautylog.ora.end()
done.resolve(config) done.resolve(config)

View File

@ -13,6 +13,7 @@ export type npmtsMode = 'default' | 'custom' | 'merge'
export interface INpmtsConfig { export interface INpmtsConfig {
argv: any argv: any
coverage: boolean
coverageTreshold: number coverageTreshold: number
checkDependencies: boolean checkDependencies: boolean
mode: npmtsMode mode: npmtsMode
@ -31,6 +32,7 @@ export let run = function (argvArg) {
let done = q.defer() let done = q.defer()
let defaultConfig: INpmtsConfig = { let defaultConfig: INpmtsConfig = {
argv: undefined, argv: undefined,
coverage: true,
coverageTreshold: 70, coverageTreshold: 70,
checkDependencies: true, checkDependencies: true,
mode: 'default', mode: 'default',
@ -65,7 +67,7 @@ export let run = function (argvArg) {
default: default:
plugins.beautylog.error(`mode not recognised! Can be default or custom`) 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' || config.mode === 'merge') { if (config.mode === 'default' || config.mode === 'merge') {
@ -75,15 +77,15 @@ export let run = function (argvArg) {
config.testTs = { config.testTs = {
'./test/**/*.ts': './test/' './test/**/*.ts': './test/'
} }
}; }
// mix with commandline // mix with commandline
if (config.argv.notest) { if (config.argv.notest) {
config.test = false config.test = false
}; }
if (config.argv.watch) { if (config.argv.watch) {
config.watch = true config.watch = true
}; }
plugins.beautylog.ok('build options are ready!') plugins.beautylog.ok('build options are ready!')
done.resolve(config) done.resolve(config)