diff --git a/package.json b/package.json index d9b9163..da6a8c9 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.19", + "version": "0.3.20", "publisher": "junstyle", "author": "junstyle", "license": "ISC", diff --git a/src/index.ts b/src/index.ts index cbed213..fafcba1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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') diff --git a/src/runAsync.ts b/src/runAsync.ts index 960b42f..c18f280 100644 --- a/src/runAsync.ts +++ b/src/runAsync.ts @@ -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);