fix #17, now computing coverage result correctly
This commit is contained in:
@ -8,7 +8,7 @@ import { projectInfo } from '../mod00/mod00.check'
|
||||
export let run = function(configArg){
|
||||
let done = q.defer()
|
||||
let config = configArg
|
||||
plugins.beautylog.ora.text('now looking at ' + 'required assets'.yellow)
|
||||
plugins.beautylog.ora.text('now looking at ' + 'required assets')
|
||||
if (config.cli === true) {
|
||||
let mainJsPath = projectInfo.packageJson.main
|
||||
let cliJsString: string = plugins.smartfile.fs.toStringSync(plugins.path.join(paths.npmtsAssetsDir,'cli.js'))
|
||||
|
@ -60,10 +60,10 @@ let checkDependencies = (configArg) => {
|
||||
process.exit(1)
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`)
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
||||
};
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`)
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
||||
}
|
||||
done.resolve(configArg)
|
||||
})
|
||||
@ -86,20 +86,20 @@ let checkDevDependencies = (configArg) => {
|
||||
})
|
||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||
for (let item of unused.devDependencies) {
|
||||
plugins.beautylog.log(`unused devDependency ${item.red}`)
|
||||
plugins.beautylog.log(`unused devDependency ${item}`)
|
||||
}
|
||||
for (let item in unused.missing) {
|
||||
plugins.beautylog.error(`unused devDependency ${item.red}`)
|
||||
plugins.beautylog.error(`unused devDependency ${item}`)
|
||||
}
|
||||
if (unused.missing.length > 0) {
|
||||
plugins.beautylog.info('exiting due to missing dependencies in package.json')
|
||||
process.exit(1)
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`)
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
||||
}
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`)
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
||||
}
|
||||
done.resolve(configArg)
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ import * as plugins from './mod00.plugins'
|
||||
export let run = function (configArg) {
|
||||
let done = q.defer()
|
||||
let config = configArg
|
||||
plugins.beautylog.ora.text('now compiling ' + 'TypeScript'.yellow)
|
||||
plugins.beautylog.ora.text('now compiling ' + 'TypeScript')
|
||||
plugins.tsn.compileGlobStringObject(config.ts, config.tsOptions, paths.cwd)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok(`compiled the module's TypeScript!`)
|
||||
|
@ -61,7 +61,7 @@ let tap = function (configArg: INpmtsConfig) {
|
||||
testFilesSmartstream.run()
|
||||
]).then(
|
||||
async () => {
|
||||
await npmtsTapBuffer.runTests()
|
||||
configArg.runData.coverageLcovInfo = await npmtsTapBuffer.runTests()
|
||||
done.resolve(configArg)
|
||||
}, (err) => {
|
||||
plugins.beautylog.error('Tests failed!')
|
||||
@ -76,25 +76,27 @@ let tap = function (configArg: INpmtsConfig) {
|
||||
return done.promise
|
||||
}
|
||||
|
||||
let handleCoverageData = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer()
|
||||
if (71 >= configArg.coverageTreshold) {
|
||||
let handleCoverageData = async (configArg: INpmtsConfig) => {
|
||||
let coverageResult = await plugins.smartcov.get.percentageFromLcovString(
|
||||
configArg.runData.coverageLcovInfo,
|
||||
2
|
||||
)
|
||||
if (coverageResult >= configArg.coverageTreshold) {
|
||||
plugins.beautylog.ok(
|
||||
`${(71).toString()}% `
|
||||
`${(coverageResult).toString()}% `
|
||||
+ `coverage exceeds your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
`${(71).toString()}% `
|
||||
`${(coverageResult).toString()}% `
|
||||
+ `coverage fails your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
plugins.beautylog.error('exiting due to coverage failure')
|
||||
if (!configArg.watch) { process.exit(1) }
|
||||
}
|
||||
done.resolve(configArg)
|
||||
return done.promise
|
||||
return configArg
|
||||
}
|
||||
|
||||
export let run = function (configArg: INpmtsConfig) {
|
||||
|
@ -4,6 +4,7 @@ import * as gulp from 'gulp'
|
||||
import * as gulpFunction from 'gulp-function'
|
||||
import * as gulpSourcemaps from 'gulp-sourcemaps'
|
||||
import * as gulpTypeScript from 'gulp-typescript'
|
||||
import * as smartcov from 'smartcov'
|
||||
import * as tapbuffer from 'tapbuffer'
|
||||
|
||||
export {
|
||||
@ -11,5 +12,6 @@ export {
|
||||
gulpFunction,
|
||||
gulpSourcemaps,
|
||||
gulpTypeScript,
|
||||
smartcov,
|
||||
tapbuffer
|
||||
}
|
||||
|
@ -6,73 +6,77 @@ import * as q from 'smartq'
|
||||
export type npmtsMode = 'default' | 'custom'
|
||||
|
||||
export interface INpmtsConfig {
|
||||
argv: any,
|
||||
coverageTreshold: number,
|
||||
mode: npmtsMode,
|
||||
test: boolean,
|
||||
testTs: any,
|
||||
ts: any,
|
||||
tsOptions: any,
|
||||
watch: boolean
|
||||
|
||||
argv: any,
|
||||
coverageTreshold: number,
|
||||
mode: npmtsMode,
|
||||
test: boolean,
|
||||
testTs: any,
|
||||
ts: any,
|
||||
tsOptions: any,
|
||||
watch: boolean
|
||||
runData: {
|
||||
coverageLcovInfo?: string,
|
||||
coverageResult?: number
|
||||
}
|
||||
};
|
||||
|
||||
export let run = function (argvArg) {
|
||||
let done = q.defer()
|
||||
let defaultConfig: INpmtsConfig = {
|
||||
argv: undefined,
|
||||
coverageTreshold: 70,
|
||||
mode: 'default',
|
||||
test: true,
|
||||
testTs: {},
|
||||
ts: {},
|
||||
tsOptions: {},
|
||||
watch: false
|
||||
let done = q.defer()
|
||||
let defaultConfig: INpmtsConfig = {
|
||||
argv: undefined,
|
||||
coverageTreshold: 70,
|
||||
mode: 'default',
|
||||
test: true,
|
||||
testTs: {},
|
||||
ts: {},
|
||||
tsOptions: {},
|
||||
watch: false,
|
||||
runData: {}
|
||||
}
|
||||
|
||||
// mix with configfile
|
||||
plugins.beautylog.ora.text('running npmextra')
|
||||
|
||||
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd)
|
||||
let config: INpmtsConfig = localNpmextra.dataFor<INpmtsConfig>(
|
||||
'npmts',
|
||||
defaultConfig
|
||||
)
|
||||
|
||||
// add argv
|
||||
config.argv = argvArg
|
||||
|
||||
// check mode
|
||||
switch (config.mode) {
|
||||
case 'default':
|
||||
case 'custom':
|
||||
plugins.beautylog.ok('mode is ' + config.mode)
|
||||
done.resolve(config)
|
||||
break
|
||||
default:
|
||||
plugins.beautylog.error(`mode not recognised!`)
|
||||
process.exit(1)
|
||||
};
|
||||
|
||||
// handle default mode
|
||||
if (config.mode === 'default') {
|
||||
config.ts = {
|
||||
'./ts/**/*.ts': './dist/'
|
||||
}
|
||||
config.testTs = {
|
||||
'./test/**/*.ts': './test/'
|
||||
}
|
||||
};
|
||||
|
||||
// mix with configfile
|
||||
plugins.beautylog.ora.text('running npmextra')
|
||||
// mix with commandline
|
||||
if (config.argv.notest) {
|
||||
config.test = false
|
||||
};
|
||||
if (config.argv.watch) {
|
||||
config.watch = true
|
||||
};
|
||||
|
||||
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd)
|
||||
let config: INpmtsConfig = localNpmextra.dataFor<INpmtsConfig>(
|
||||
'npmts',
|
||||
defaultConfig
|
||||
)
|
||||
|
||||
// add argv
|
||||
config.argv = argvArg
|
||||
|
||||
// check mode
|
||||
switch (config.mode) {
|
||||
case 'default':
|
||||
case 'custom':
|
||||
plugins.beautylog.ok('mode is ' + config.mode)
|
||||
done.resolve(config)
|
||||
break
|
||||
default:
|
||||
plugins.beautylog.error(`mode not recognised!`)
|
||||
process.exit(1)
|
||||
};
|
||||
|
||||
// handle default mode
|
||||
if (config.mode === 'default') {
|
||||
config.ts = {
|
||||
'./ts/**/*.ts': './dist/'
|
||||
}
|
||||
config.testTs = {
|
||||
'./test/**/*.ts': './test/'
|
||||
}
|
||||
};
|
||||
|
||||
// mix with commandline
|
||||
if (config.argv.notest) {
|
||||
config.test = false
|
||||
};
|
||||
if (config.argv.watch) {
|
||||
config.watch = true
|
||||
};
|
||||
|
||||
plugins.beautylog.ok('build options are ready!')
|
||||
done.resolve(config)
|
||||
return done.promise
|
||||
plugins.beautylog.ok('build options are ready!')
|
||||
done.resolve(config)
|
||||
return done.promise
|
||||
}
|
||||
|
Reference in New Issue
Block a user