From fab8d0a089b7b0c7c99d4b753798629da63b53ad Mon Sep 17 00:00:00 2001 From: junstyle Date: Tue, 13 Aug 2024 23:06:31 +0800 Subject: [PATCH] maybe fix: https://github.com/junstyle/vscode-php-cs-fixer/issues/217 https://github.com/junstyle/vscode-php-cs-fixer/issues/216 --- package.json | 2 +- src/runAsync.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9859de3..f23b5d0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "php-cs-fixer", "displayName": "php cs fixer", "description": "PHP CS Fixer extension for VS Code, php formatter, php code beautify tool, format html", - "version": "0.3.14", + "version": "0.3.15", "publisher": "junstyle", "author": "junstyle", "license": "ISC", diff --git a/src/runAsync.ts b/src/runAsync.ts index 07e9302..9dc723f 100644 --- a/src/runAsync.ts +++ b/src/runAsync.ts @@ -2,13 +2,17 @@ import { spawn, SpawnOptionsWithoutStdio } from 'child_process'; import { output } from './output'; export function runAsync(command: string, args: string[], options: SpawnOptionsWithoutStdio, onData: (data: Buffer) => void = null) { - const cpOptions = Object.assign({}, options, { shell: true, }) + const cpOptions = Object.assign({}, options, { shell: process.platform == 'win32', }) let cp; try { output('runAsync: spawn ' + command); output(JSON.stringify(args, null, 2)) output(JSON.stringify(cpOptions, null, 2)) + if (process.platform == 'win32' && command.includes(" ") && command[0] != '"') { + command = '"' + command + '"' + } + cp = spawn(command, args, cpOptions) } catch (err) { const promise = new Promise((resolve, reject) => { @@ -17,7 +21,7 @@ export function runAsync(command: string, args: string[], options: SpawnOptionsW output('runAsync: reject promise') reject(err) }) - ; (promise as any).cp = cp + ; (promise as any).cp = cp return promise }