Skip to content

Commit a8373f0

Browse files
authored
fix(toolkits/pro): An error message is displayed when the dependency installation fails (#117)
* fix(toolkits/pro): An error message is displayed when the dependency installation fails
1 parent 7b6db16 commit a8373f0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • packages/toolkits/pro/src/lib

packages/toolkits/pro/src/lib/init.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,27 @@ export const installDependencies = (answers: ProjectInfo) => {
291291
// egg服务端 安装依赖并启动
292292
if (serverConfirm && serverFramework === ServerFrameworks.EggJs) {
293293
log.info('正在安装服务端 npm 依赖,安装过程需要几十秒,请耐心等待...');
294-
spawn.sync('npm', ['install'], {
294+
const installServiceResult = spawn.sync('npm', ['install'], {
295295
cwd: `${name}/${serverFramework}/`,
296296
stdio: 'inherit',
297297
});
298-
log.success('服务端 npm 依赖安装成功');
298+
if(installServiceResult.status === 0) {
299+
log.success('服务端 npm 依赖安装成功');
300+
}else {
301+
throw new Error(installServiceResult.error);
302+
}
299303
}
300304
// npm 依赖安装
301305
log.info('正在安装客户端 npm 依赖,安装过程需要几十秒,请耐心等待...');
302-
spawn.sync('npm', ['install'], {
306+
const installClientResult = spawn.sync('npm', ['install'], {
303307
cwd: serverConfirm ? `${name}/web` : `${name}/`,
304308
stdio: 'inherit',
305309
});
306-
log.success('客户端 npm 依赖安装成功');
310+
if(installClientResult.status === 0) {
311+
log.success('客户端 npm 依赖安装成功');
312+
}else {
313+
throw new Error(installClientResult.error);
314+
}
307315

308316
/* prettier-ignore-start */
309317
console.log(

0 commit comments

Comments
 (0)