Fixes #288. Add custom command for PHP-CS-Fixer on Windows
This commit is contained in:
parent
3913267804
commit
bb3b9c99a7
|
@ -14,12 +14,27 @@ module.exports = class PHPCSFixer extends Beautifier
|
|||
|
||||
beautify: (text, language, options) ->
|
||||
@debug('php-cs-fixer', options)
|
||||
@run("php-cs-fixer", [
|
||||
"fix"
|
||||
"--level=#{options.level}" if options.level
|
||||
"--fixers=#{options.fixers}" if options.fixers
|
||||
tempFile = @tempFile("temp", text)
|
||||
], {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
|
||||
isWin = /^win/.test(process.platform)
|
||||
|
||||
if isWin
|
||||
@run("php", [
|
||||
options.cs_fixer_path or "php-cs-fixer.phar"
|
||||
"fix"
|
||||
"--level=#{options.level}" if options.level
|
||||
"--fixers=#{options.fixers}" if options.fixers
|
||||
tempFile = @tempFile("temp", text)
|
||||
], {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
else
|
||||
@run("php-cs-fixer", [
|
||||
"fix"
|
||||
"--level=#{options.level}" if options.level
|
||||
"--fixers=#{options.fixers}" if options.fixers
|
||||
tempFile = @tempFile("temp", text)
|
||||
], {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
|
|
|
@ -18,6 +18,10 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
cs_fixer_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `php-cs-fixer` CLI executable"
|
||||
fixers:
|
||||
type: 'string'
|
||||
default: ""
|
||||
|
|
Loading…
Reference in New Issue