@wgoo/cli
Version:
Wgoo Cli 是一个 React 组件库构建工具,通过 Wgoo Cli 可以快速搭建一套功能完备的 React 组件库。
39 lines (32 loc) • 884 B
JavaScript
const { runCLI } = require('jest');
const { setNodeEnv } = require('../common');
const { genPackageEntry } = require('../compiler/gen-package-entry');
const { ROOT, JEST_CONFIG_FILE, PACKAGE_ENTRY_FILE } = require('../common/constant');
function test(command) {
setNodeEnv('test');
genPackageEntry({
outputPath: PACKAGE_ENTRY_FILE,
});
const config = {
rootDir: ROOT,
watch: command.watch,
config: JEST_CONFIG_FILE,
clearCache: command.clearCache,
// make jest tests faster
// see: https://ivantanev.com/make-jest-faster/
maxWorkers: '50%',
};
runCLI(config, [ROOT])
.then((response) => {
if (!response.results.success && !command.watch) {
process.exit(1);
}
})
.catch((err) => {
console.log(err);
if (!command.watch) {
process.exit(1);
}
});
}
module.exports = { test };