From ae2442be3cbc6cdddc98e2d7761ed05594361da6 Mon Sep 17 00:00:00 2001 From: liberty-zlk Date: Thu, 2 Nov 2023 03:46:14 -0700 Subject: [PATCH 1/3] feat(toolkits/pro) An error message is displayed when the dependency installation fails --- packages/toolkits/pro/src/lib/init.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index c4337a22..a50de13e 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -291,19 +291,32 @@ export const installDependencies = (answers: ProjectInfo) => { // egg服务端 安装依赖并启动 if (serverConfirm && serverFramework === ServerFrameworks.EggJs) { log.info('正在安装服务端 npm 依赖,安装过程需要几十秒,请耐心等待...'); - spawn.sync('npm', ['install'], { + const installServiceResult = spawn.sync('npm', ['install'], { cwd: `${name}/${serverFramework}/`, stdio: 'inherit', }); - log.success('服务端 npm 依赖安装成功'); + if(installServiceResult.status === 0) { + log.success('服务端 npm 依赖安装成功'); + }else { + log.error('服务端 npm 依赖安装失败'); + log.info('请手动执行 tiny i 或 npm i'); + return; + } + } // npm 依赖安装 log.info('正在安装客户端 npm 依赖,安装过程需要几十秒,请耐心等待...'); - spawn.sync('npm', ['install'], { + const installClientResult = spawn.sync('npm', ['install'], { cwd: serverConfirm ? `${name}/web` : `${name}/`, stdio: 'inherit', }); - log.success('客户端 npm 依赖安装成功'); + if(installClientResult.status === 0) { + log.success('客户端 npm 依赖安装成功'); + }else { + log.error('客户端 npm 依赖安装失败'); + log.info('请手动执行 tiny i 或 npm i'); + return; + } /* prettier-ignore-start */ console.log( @@ -384,7 +397,6 @@ export default async () => { try { installDependencies(projectInfo); } catch (e) { - log.error('npm 依赖安装失败'); - log.info('请手动执行 tiny i 或 npm i'); + return; } }; From 179a976c2c9521473a07ff6a24959c8174308160 Mon Sep 17 00:00:00 2001 From: liberty-zlk Date: Fri, 3 Nov 2023 00:26:41 -0700 Subject: [PATCH 2/3] feat(toolkits/pro) An error message is displayed when the dependency installation fails --- packages/toolkits/pro/src/lib/init.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index a50de13e..67f9f233 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -298,9 +298,7 @@ export const installDependencies = (answers: ProjectInfo) => { if(installServiceResult.status === 0) { log.success('服务端 npm 依赖安装成功'); }else { - log.error('服务端 npm 依赖安装失败'); - log.info('请手动执行 tiny i 或 npm i'); - return; + throw new Error(installServiceResult.error); } } @@ -313,9 +311,7 @@ export const installDependencies = (answers: ProjectInfo) => { if(installClientResult.status === 0) { log.success('客户端 npm 依赖安装成功'); }else { - log.error('客户端 npm 依赖安装失败'); - log.info('请手动执行 tiny i 或 npm i'); - return; + throw new Error(installClientResult.error); } /* prettier-ignore-start */ @@ -397,6 +393,7 @@ export default async () => { try { installDependencies(projectInfo); } catch (e) { - return; + log.error('npm 依赖安装失败'); + log.info('请手动执行 tiny i 或 npm i'); } }; From 66b425bc9b48236756c90283dfe3ea1e59c1ad41 Mon Sep 17 00:00:00 2001 From: liberty-zlk Date: Fri, 3 Nov 2023 00:48:22 -0700 Subject: [PATCH 3/3] feat(toolkits/pro) An error message is displayed when the dependency installation fails --- packages/toolkits/pro/src/lib/init.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index 67f9f233..bfeb1e89 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -300,7 +300,6 @@ export const installDependencies = (answers: ProjectInfo) => { }else { throw new Error(installServiceResult.error); } - } // npm 依赖安装 log.info('正在安装客户端 npm 依赖,安装过程需要几十秒,请耐心等待...');