From 63f3202241d89d66a9c9adc6d3d9e13e3b133b02 Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 20 Oct 2022 01:35:14 +0800 Subject: [PATCH] install: rollback resolution field --- install/install.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/install/install.ts b/install/install.ts index 10b83944..46e2b737 100644 --- a/install/install.ts +++ b/install/install.ts @@ -120,11 +120,12 @@ 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`; - const data = existsSync(pkgjson) ? require(pkgjson) : {}; + data = existsSync(pkgjson) ? require(pkgjson) : {}; data.resolutions = data.resolutions || {}; Object.assign(data.resolutions, Object.fromEntries([ '@esbuild/linux-loong64', @@ -142,6 +143,15 @@ function removeOptionalEsbuildDeps() { return true; } +function rollbackResolveField() { + const yarnGlobalPath = exec('yarn global dir').output?.trim() || ''; + if (!yarnGlobalPath) return false; + const pkgjson = `${yarnGlobalPath}/package.json`; + delete data.resolutions; + writeFileSync(pkgjson, JSON.stringify(data, null, 2)); + return true; +} + const steps = [ { init: 'install.preparing', @@ -259,6 +269,7 @@ const steps = [ }, () => log.info('extra.dbUser'), () => log.info('extra.dbPassword', password), + () => rollbackResolveField(), ], }, ];