mirror of
https://github.com/pnpm/action-setup.git
synced 2026-11-03 20:40:57 +00:00
fix: preserve Windows command paths containing spaces
This commit is contained in:
+6
-10
@@ -1,4 +1,5 @@
|
||||
import { addPath, exportVariable } from '@actions/core'
|
||||
import { exec } from '@actions/exec'
|
||||
import { spawn } from 'child_process'
|
||||
import { rm, writeFile, mkdir, symlink } from 'fs/promises'
|
||||
import { readFileSync, existsSync } from 'fs'
|
||||
@@ -209,7 +210,7 @@ function targetsPnpm12(version: string): boolean {
|
||||
|
||||
function getSystemNodeVersion(): Promise<{ major: number; minor: number }> {
|
||||
return new Promise((resolve) => {
|
||||
const cp = spawn('node', ['--version'], { stdio: ['pipe', 'pipe', 'pipe'], shell: process.platform === 'win32' })
|
||||
const cp = spawn('node', ['--version'], { stdio: ['pipe', 'pipe', 'pipe'] })
|
||||
let output = ''
|
||||
cp.stdout.on('data', (data: Buffer) => { output += data.toString() })
|
||||
cp.on('close', () => {
|
||||
@@ -221,15 +222,10 @@ function getSystemNodeVersion(): Promise<{ major: number; minor: number }> {
|
||||
}
|
||||
|
||||
function runCommand(cmd: string, args: string[], opts: { cwd: string; env?: Record<string, string | undefined> }): Promise<number> {
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
const cp = spawn(cmd, args, {
|
||||
cwd: opts.cwd,
|
||||
env: opts.env,
|
||||
stdio: ['pipe', 'inherit', 'inherit'],
|
||||
shell: process.platform === 'win32',
|
||||
})
|
||||
cp.on('error', reject)
|
||||
cp.on('close', resolve)
|
||||
return exec(`"${cmd}"`, args, {
|
||||
cwd: opts.cwd,
|
||||
env: opts.env && Object.fromEntries(Object.entries(opts.env).filter((entry): entry is [string, string] => entry[1] !== undefined)),
|
||||
ignoreReturnCode: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user