Skip to content

Commit

Permalink
optimize spawn args. v0.3.20
Browse files Browse the repository at this point in the history
  • Loading branch information
junstyle committed Sep 4, 2024
1 parent cef4da2 commit 7e4d175
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.19",
"version": "0.3.20",
"publisher": "junstyle",
"author": "junstyle",
"license": "ISC",
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ class PHPCSFixer extends PHPCSFixerConfig {
}
}
if (!useConfig && this.rules) {
args.push('--rules="' + (this.rules as string).replace(/"/g, "\\\"") + '"')
if (process.platform == 'win32') {
args.push('--rules="' + (this.rules as string).replace(/"/g, "\\\"") + '"')
} else {
args.push('--rules=' + this.rules)
}
}
if (this.allowRisky) {
args.push('--allow-risky=yes')
Expand Down
8 changes: 5 additions & 3 deletions src/runAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ 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 {
if (command.includes(" ") && command[0] != '"') {
command = '"' + command + '"'
if (process.platform == 'win32') {
if (command.includes(" ") && command[0] != '"') {
command = '"' + command + '"'
}
}

output('runAsync: spawn ' + command);
Expand Down

0 comments on commit 7e4d175

Please sign in to comment.