Skip to content

Commit

Permalink
fix --rules on linux os
Browse files Browse the repository at this point in the history
  • Loading branch information
junstyle committed Aug 15, 2024
1 parent b3ab97d commit 70b9d9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18455,7 +18455,14 @@ var PHPCSFixer = class extends PHPCSFixerConfig {
}
}
if (!useConfig && this.rules) {
args.push('--rules="' + this.rules.replace(/"/g, '\\"') + '"');
let rules = this.rules;
if (process.platform === "win32") {
rules = '"' + rules.replace(/"/g, '\\"') + '"';
} else {
rules = rules.replace(/\s+/g, "");
statusInfo("rules can't contain whitespaces on linux os!");
}
args.push("--rules=" + rules);
}
if (this.allowRisky) {
args.push("--allow-risky=yes");
Expand Down
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.17",
"version": "0.3.18",
"publisher": "junstyle",
"author": "junstyle",
"license": "ISC",
Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ class PHPCSFixer extends PHPCSFixerConfig {
}
}
if (!useConfig && this.rules) {
const rules = process.platform === 'win32'
? ('"' + (this.rules as string).replace(/"/g, "\\\"") + '"')
: this.rules
let rules = this.rules as string
if (process.platform === 'win32') {
rules = '"' + rules.replace(/"/g, "\\\"") + '"'
} else {
rules = rules.replace(/\s+/g, '')
statusInfo("rules can't contain whitespaces on linux os!")
}
args.push('--rules=' + rules)
}
if (this.allowRisky) {
Expand Down

0 comments on commit 70b9d9f

Please sign in to comment.