run脚本加入了对mode的判断

This commit is contained in:
Xu Chang 2022-07-11 18:18:16 +08:00
parent d98146b5ff
commit 29c48d1a4d
5 changed files with 17 additions and 4 deletions

View File

@ -1,4 +1,5 @@
/// <reference types="node" />
/// <reference types="node" />
import { PathLike } from 'fs';
import { checkFileExistsAndCreateType } from './enum';
/**

View File

@ -77,6 +77,7 @@ commander_1.default
commander_1.default
.command('run')
.option('-i, --initialize', 'true')
.option('-m, --mode <mode>', 'mode')
.description(`run backend server by ${config_1.CLI_NAME}`)
.action(run_1.default);
// output help information on unknown commands

View File

@ -24,8 +24,13 @@ async function run(options) {
}
else {
(0, tip_style_1.Success)(`${(0, tip_style_1.success)('启动服务器……')}`);
console.log(options.mode);
// ts-node scripts/build-app-domain & npm link ./app-domain
const result = cross_spawn_1.default.sync('ts-node', [require.resolve('../scripts/' + 'start-server.js')], {
const result = cross_spawn_1.default.sync(`cross-env`, [
`NODE_ENV=${options.mode}`,
'ts-node',
require.resolve('../scripts/' + 'start-server.js'),
], {
stdio: 'inherit',
shell: true,
});

View File

@ -79,6 +79,7 @@ program
program
.command('run')
.option('-i, --initialize', 'true')
.option('-m, --mode <mode>', 'mode')
.description(`run backend server by ${CLI_NAME}`)
.action(run);
// output help information on unknown commands

View File

@ -31,10 +31,15 @@ export default async function run(options: any): Promise<void> {
}
else {
Success(`${success('启动服务器……')}`);
console.log(options.mode);
// ts-node scripts/build-app-domain & npm link ./app-domain
const result = spawn.sync(
'ts-node',
[require.resolve('../scripts/' + 'start-server.js')],
const result = spawn.sync(
`cross-env`,
[
`NODE_ENV=${options.mode}`,
'ts-node',
require.resolve('../scripts/' + 'start-server.js'),
],
{
stdio: 'inherit',
shell: true,