From d09ce5c3eee93932656248b23772eacd29524d68 Mon Sep 17 00:00:00 2001 From: yexi Date: Sat, 31 Oct 2026 21:47:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20pnpm=20=E6=97=B6=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E8=B7=A8=E5=AD=98=E5=82=A8=E7=A1=AE=E8=AE=A4=E9=98=BB=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/node.js | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/node.js b/src/node.js index 1ebc61c..d59bb62 100644 --- a/src/node.js +++ b/src/node.js @@ -82,37 +82,19 @@ async function readJsonFile(filePath) { } } -/** Detect the pnpm storeDir recorded in a profile's node_modules/.modules.yaml. */ -async function detectProfileStoreDir(profileDir) { - const modulesYamlPath = path.join(profileDir, 'node_modules', '.modules.yaml') - try { - const raw = await fs.readFile(modulesYamlPath, 'utf8') - try { - const parsed = JSON.parse(raw) - if (typeof parsed?.storeDir === 'string' && parsed.storeDir.trim() !== '') { - return parsed.storeDir.trim() - } - } catch { - const match = raw.match(/^\s*"?storeDir"?\s*:\s*"?([^"\r\n]+)"?/m) - if (match?.[1]) return match[1].trim() - } - } catch { - // No .modules.yaml yet; let pnpm pick its default store. - } - return undefined -} - /** Run pnpm inside a profile directory using Desktop's bundled runtime or system pnpm. */ -async function runPnpm(profileDir, args, packageManager) { +function runPnpm(profileDir, args, packageManager) { const command = packageManager?.command ?? (process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm') - const storeDir = await detectProfileStoreDir(profileDir) - const storeArgs = storeDir !== undefined ? ['--store-dir', storeDir] : [] - const fullArgs = [...(packageManager?.argsPrefix ?? []), '--dir', profileDir, ...storeArgs, ...args] - const env = { - ...process.env, - ...(packageManager?.env ?? {}), - ...(storeDir !== undefined ? { npm_config_store_dir: storeDir } : {}), - } + const fullArgs = [ + ...(packageManager?.argsPrefix ?? []), + '--dir', + profileDir, + '--config.confirmModulesPurge=false', + ...args, + ] + const env = packageManager?.env !== undefined + ? { ...process.env, ...packageManager.env } + : process.env const useShell = packageManager?.command === undefined && process.platform === 'win32' return new Promise((resolve, reject) => { execFile(