diff --git a/dist/index.js b/dist/index.js index 885a0c2..51d7b73 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index 6499130..9c035ef 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -60,6 +60,10 @@ export async function runSelfInstaller(inputs: Inputs): Promise { } } + // Create pn/pnx alias symlinks if the installed version supports them + // (pnpm v11+ adds pn and pnx as short aliases) + await ensureAliasLinks(pnpmHome, standalone) + return 0 } @@ -118,6 +122,19 @@ Please specify it by one of the following ways: - in the package.json with the key "packageManager"`) } +async function ensureAliasLinks(pnpmHome: string, standalone: boolean): Promise { + const aliases = standalone + ? { pn: path.join('..', '@pnpm', 'exe', 'pn'), pnpx: path.join('..', '@pnpm', 'exe', 'pnpx'), pnx: path.join('..', '@pnpm', 'exe', 'pnx') } + : { pn: path.join('..', 'pnpm', 'bin', 'pnpm.cjs'), pnpx: path.join('..', 'pnpm', 'bin', 'pnpx.cjs'), pnx: path.join('..', 'pnpm', 'bin', 'pnpx.cjs') } + for (const [name, target] of Object.entries(aliases)) { + const link = path.join(pnpmHome, name) + const resolvedTarget = path.resolve(pnpmHome, target) + if (!existsSync(link) && existsSync(resolvedTarget)) { + await symlink(target, link) + } + } +} + function runCommand(cmd: string, args: string[], opts: { cwd: string }): Promise { return new Promise((resolve, reject) => { const cp = spawn(cmd, args, {