feat(setup): stop creating windows scripts on posix (#8418)

This commit is contained in:
Khải
2024-08-14 17:03:55 +07:00
committed by GitHub
parent e08c416cfd
commit 769165832a
2 changed files with 16 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-setup": patch
"pnpm": patch
---
`pnpm setup` no longer creates Batch/Powershell scripts on Linux and macOS.

View File

@@ -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 (