From 769165832af2df7977ce8e86a6e4152c655aa698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=E1=BA=A3i?= Date: Wed, 14 Aug 2024 17:03:55 +0700 Subject: [PATCH] feat(setup): stop creating windows scripts on posix (#8418) --- .changeset/four-clocks-cry.md | 6 ++++++ packages/plugin-commands-setup/src/setup.ts | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .changeset/four-clocks-cry.md diff --git a/.changeset/four-clocks-cry.md b/.changeset/four-clocks-cry.md new file mode 100644 index 0000000000..e5a1a15340 --- /dev/null +++ b/.changeset/four-clocks-cry.md @@ -0,0 +1,6 @@ +--- +"@pnpm/plugin-commands-setup": patch +"pnpm": patch +--- + +`pnpm setup` no longer creates Batch/Powershell scripts on Linux and macOS. diff --git a/packages/plugin-commands-setup/src/setup.ts b/packages/plugin-commands-setup/src/setup.ts index 40da77456e..2896a88053 100644 --- a/packages/plugin-commands-setup/src/setup.ts +++ b/packages/plugin-commands-setup/src/setup.ts @@ -72,20 +72,23 @@ function createPnpxScripts (targetDir: string): void { fs.mkdirSync(targetDir, { recursive: true }) + // windows can also use shell script via mingw or cygwin so no filter const shellScript = [ '#!/bin/sh', 'exec pnpm dlx "$@"', ].join('\n') fs.writeFileSync(path.join(targetDir, 'pnpx'), shellScript, { mode: 0o755 }) - const batchScript = [ - '@echo off', - 'pnpm dlx %*', - ].join('\n') - fs.writeFileSync(path.join(targetDir, 'pnpx.cmd'), batchScript) + if (process.platform === 'win32') { + const batchScript = [ + '@echo off', + 'pnpm dlx %*', + ].join('\n') + fs.writeFileSync(path.join(targetDir, 'pnpx.cmd'), batchScript) - const powershellScript = 'pnpm dlx $args' - fs.writeFileSync(path.join(targetDir, 'pnpx.ps1'), powershellScript) + const powershellScript = 'pnpm dlx $args' + fs.writeFileSync(path.join(targetDir, 'pnpx.ps1'), powershellScript) + } } export async function handler (