chore(cli): set node env

This commit is contained in:
陈嘉涵 2019-11-29 17:38:26 +08:00
parent 9318e6b909
commit 6f1b24663e
2 changed files with 7 additions and 3 deletions

View File

@ -1,8 +1,9 @@
import { runCLI } from 'jest';
import { setNodeEnv } from '../common';
import { CWD, JEST_CONFIG_FILE } from '../common/constant';
export function test(command: any) {
process.env.NODE_ENV = 'test';
setNodeEnv('test');
const config = {
rootDir: CWD,

View File

@ -88,11 +88,14 @@ export function getWebpackConfig(): object {
return {};
}
export function setModuleEnv(value: 'esmodule' | 'commonjs') {
export type ModuleEnv = 'esmodule' | 'commonjs';
export type NodeEnv = 'production' | 'development' | 'test';
export function setModuleEnv(value: ModuleEnv) {
process.env.BABEL_MODULE = value;
}
export function setNodeEnv(value: 'production' | 'development') {
export function setNodeEnv(value: NodeEnv) {
process.env.NODE_ENV = value;
}