change npmts package name to being @gitzone scoped
This commit is contained in:
@ -1,136 +1,141 @@
|
||||
/* ------------------------------------------
|
||||
* This module tests the compiled TypeScript files
|
||||
* -------------------------------------------- */
|
||||
import plugins = require('./mod.plugins')
|
||||
import paths = require('../npmts.paths')
|
||||
import plugins = require('./mod.plugins');
|
||||
import paths = require('../npmts.paths');
|
||||
|
||||
import * as q from 'smartq'
|
||||
import * as q from 'smartq';
|
||||
|
||||
// interfaces
|
||||
import { INpmtsConfig } from '../npmts.config'
|
||||
import { Smartfile } from 'smartfile'
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
import { Smartfile } from 'smartfile';
|
||||
|
||||
let testTypeScriptConfig = {
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: [
|
||||
'DOM',
|
||||
'ESNext'
|
||||
]
|
||||
}
|
||||
lib: ['DOM', 'ESNext']
|
||||
};
|
||||
|
||||
/**
|
||||
* runs mocha
|
||||
* @returns INpmtsConfig
|
||||
*/
|
||||
let tap = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer()
|
||||
let tap = function(configArg: INpmtsConfig) {
|
||||
let done = q.defer();
|
||||
|
||||
/**
|
||||
* the TabBuffer for npmts
|
||||
*/
|
||||
let npmtsTapBuffer = new plugins.tapbuffer.TabBuffer()
|
||||
let npmtsTapBuffer = new plugins.tapbuffer.TabBuffer();
|
||||
|
||||
npmtsTapBuffer.setConfig(configArg.testConfig)
|
||||
npmtsTapBuffer.setConfig(configArg.testConfig);
|
||||
|
||||
/**
|
||||
* handle the testable files
|
||||
*/
|
||||
let testableFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.smartgulp.src([ plugins.path.join(paths.cwd, './ts/**/*.ts') ]),
|
||||
plugins.smartgulp.src([plugins.path.join(paths.cwd, './ts/**/*.ts')]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript(testTypeScriptConfig),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
npmtsTapBuffer.pipeTestableFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
])
|
||||
]);
|
||||
|
||||
/**
|
||||
* handle the test files
|
||||
*/
|
||||
let testFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.smartgulp.src([ plugins.path.join(paths.cwd, 'test/*.ts') ]),
|
||||
plugins.smartgulp.src([plugins.path.join(paths.cwd, 'test/*.ts')]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript(testTypeScriptConfig),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
npmtsTapBuffer.pipeTestFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
])
|
||||
]);
|
||||
|
||||
// lets run the smartstream
|
||||
Promise.all([
|
||||
testableFilesSmartstream.run(),
|
||||
testFilesSmartstream.run()
|
||||
]).then(
|
||||
Promise.all([testableFilesSmartstream.run(), testFilesSmartstream.run()]).then(
|
||||
async () => {
|
||||
configArg.runData.coverageLcovInfo = await npmtsTapBuffer.runTests()
|
||||
done.resolve(configArg)
|
||||
}, (err) => {
|
||||
plugins.beautylog.error('Tests failed!')
|
||||
console.log(err)
|
||||
configArg.runData.coverageLcovInfo = await npmtsTapBuffer.runTests();
|
||||
done.resolve(configArg);
|
||||
},
|
||||
err => {
|
||||
plugins.beautylog.error('Tests failed!');
|
||||
console.log(err);
|
||||
if (configArg.watch) {
|
||||
done.resolve(configArg)
|
||||
done.resolve(configArg);
|
||||
} else {
|
||||
process.exit(1)
|
||||
process.exit(1);
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
return done.promise
|
||||
}
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let handleCoverageData = async (configArg: INpmtsConfig) => {
|
||||
let coverageResult: number = 0 // the coverage in percent
|
||||
let coverageResult: number = 0; // the coverage in percent
|
||||
if (configArg.runData.coverageLcovInfo) {
|
||||
coverageResult = await plugins.smartcov.get.percentageFromLcovString(
|
||||
configArg.runData.coverageLcovInfo,
|
||||
2
|
||||
)
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.warn('Hey... Did your tests import and use your module that you are trying to test?')
|
||||
plugins.beautylog.warn(
|
||||
'Hey... Did your tests import and use your module that you are trying to test?'
|
||||
);
|
||||
}
|
||||
|
||||
if (coverageResult >= configArg.coverageTreshold) {
|
||||
plugins.beautylog.ok(
|
||||
`${(coverageResult).toString()}% `
|
||||
+ `coverage exceeds your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
`${coverageResult.toString()}% ` +
|
||||
`coverage exceeds your treshold of ` +
|
||||
`${configArg.coverageTreshold.toString()}%`
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
`${(coverageResult).toString()}% `
|
||||
+ `coverage fails your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
plugins.beautylog.error('exiting due to coverage failure')
|
||||
if (!configArg.watch) { process.exit(1) }
|
||||
`${coverageResult.toString()}% ` +
|
||||
`coverage fails your treshold of ` +
|
||||
`${configArg.coverageTreshold.toString()}%`
|
||||
);
|
||||
plugins.beautylog.error('exiting due to coverage failure');
|
||||
if (!configArg.watch) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
return configArg
|
||||
}
|
||||
return configArg;
|
||||
};
|
||||
|
||||
export let run = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer<INpmtsConfig>()
|
||||
let config = configArg
|
||||
export let run = function(configArg: INpmtsConfig) {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
let config = configArg;
|
||||
if (config.test === true) {
|
||||
plugins.beautylog.ora.text('now starting tests')
|
||||
plugins.beautylog.ora.end()
|
||||
plugins.beautylog.log('ready for tapbuffer:')
|
||||
plugins.beautylog.ora.text('now starting tests');
|
||||
plugins.beautylog.ora.end();
|
||||
plugins.beautylog.log('ready for tapbuffer:');
|
||||
if (configArg.testConfig.coverage) {
|
||||
tap(config)
|
||||
.then(handleCoverageData)
|
||||
.then(() => {
|
||||
done.resolve(config)
|
||||
}).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) })
|
||||
done.resolve(config);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
plugins.beautylog.ora.end()
|
||||
done.resolve(config)
|
||||
plugins.beautylog.ora.end();
|
||||
done.resolve(config);
|
||||
}
|
||||
return done.promise
|
||||
}
|
||||
return done.promise;
|
||||
};
|
||||
|
@ -1,17 +1,10 @@
|
||||
export * from '../npmts.plugins'
|
||||
export * from '../npmts.plugins';
|
||||
|
||||
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 smartgulp from 'smartgulp'
|
||||
import * as tapbuffer from 'tapbuffer'
|
||||
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 smartgulp from 'smartgulp';
|
||||
import * as tapbuffer from 'tapbuffer';
|
||||
|
||||
export {
|
||||
gulpFunction,
|
||||
gulpSourcemaps,
|
||||
gulpTypeScript,
|
||||
smartcov,
|
||||
smartgulp,
|
||||
tapbuffer
|
||||
}
|
||||
export { gulpFunction, gulpSourcemaps, gulpTypeScript, smartcov, smartgulp, tapbuffer };
|
||||
|
Reference in New Issue
Block a user