From a5bedcb1e7b2cd8d3cb9fab1c3845046b5ee0ec7 Mon Sep 17 00:00:00 2001 From: merceyz Date: Sun, 25 Oct 2020 13:56:38 +0100 Subject: [PATCH] fix: use hardlink for the node executable --- packages/yarnpkg-core/sources/scriptUtils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/yarnpkg-core/sources/scriptUtils.ts b/packages/yarnpkg-core/sources/scriptUtils.ts index fb74fe426856..39f102eb227a 100644 --- a/packages/yarnpkg-core/sources/scriptUtils.ts +++ b/packages/yarnpkg-core/sources/scriptUtils.ts @@ -31,8 +31,8 @@ enum PackageManager { async function makePathWrapper(location: PortablePath, name: Filename, argv0: NativePath, args: Array = []) { if (process.platform === `win32`) { await Promise.all([ - // xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe`}), getBinjumper()), - // xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe.info`}), [argv0, ...args].join(`\n`)), + xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe`}), getBinjumper()), + xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe.info`}), [argv0, ...args].join(`\n`)), xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.cmd`}), `@"${argv0}" ${args.map(arg => `"${arg.replace(`"`, `""`)}"`).join(` `)} %*\n`), ]); } @@ -78,7 +78,8 @@ export async function makeScriptEnv({project, binFolder, lifecycleScript}: {proj // Register some binaries that must be made available in all subprocesses // spawned by Yarn (we thus ensure that they always use the right version) - await makePathWrapper(binFolder, `node` as Filename, process.execPath); + const execPath = npath.toPortablePath(process.execPath); + await xfs.linkPromise(execPath, ppath.join(binFolder, ppath.basename(execPath))); if (YarnVersion !== null) { await makePathWrapper(binFolder, `run` as Filename, process.execPath, [process.argv[1], `run`]);