From 1ee6ca7bef2b91501aa005e2609596bbb2451e04 Mon Sep 17 00:00:00 2001 From: Chareice Date: Tue, 22 Oct 2024 15:16:39 +0800 Subject: [PATCH] chore: ignore error when write to exclude --- packages/core/cli/src/commands/postinstall.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/cli/src/commands/postinstall.js b/packages/core/cli/src/commands/postinstall.js index 539afdf8b7..a0fc7a3fd2 100644 --- a/packages/core/cli/src/commands/postinstall.js +++ b/packages/core/cli/src/commands/postinstall.js @@ -18,9 +18,16 @@ function writeToExclude() { const excludePath = resolve(process.cwd(), '.git', 'info', 'exclude'); const content = 'packages/pro-plugins/\n'; const dirPath = dirname(excludePath); + if (!existsSync(dirPath)) { - mkdirSync(dirPath, { recursive: true }); + try { + mkdirSync(dirPath, { recursive: true }); + } catch (e) { + console.log(`${e.message}, ignore write to git exclude`); + return; + } } + let fileContent = ''; if (existsSync(excludePath)) { fileContent = readFileSync(excludePath, 'utf-8');