From 39e3d057fa8c819c11449fffe98c606362f85f76 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 21 Oct 2022 15:10:22 +0800 Subject: [PATCH] install: fix package.json --- install/install.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/install.ts b/install/install.ts index 46e2b737..6df05eca 100644 --- a/install/install.ts +++ b/install/install.ts @@ -120,12 +120,11 @@ uid: 1536 gid: 1536 `; -let data; function removeOptionalEsbuildDeps() { const yarnGlobalPath = exec('yarn global dir').output?.trim() || ''; if (!yarnGlobalPath) return false; const pkgjson = `${yarnGlobalPath}/package.json`; - data = existsSync(pkgjson) ? require(pkgjson) : {}; + const data = existsSync(pkgjson) ? require(pkgjson) : {}; data.resolutions = data.resolutions || {}; Object.assign(data.resolutions, Object.fromEntries([ '@esbuild/linux-loong64', @@ -147,6 +146,7 @@ function rollbackResolveField() { const yarnGlobalPath = exec('yarn global dir').output?.trim() || ''; if (!yarnGlobalPath) return false; const pkgjson = `${yarnGlobalPath}/package.json`; + const data = JSON.parse(readFileSync(pkgjson, 'utf-8')); delete data.resolutions; writeFileSync(pkgjson, JSON.stringify(data, null, 2)); return true;