Fixes #288. Add custom command for PHP-CS-Fixer on Windows

This commit is contained in:
Glavin Wiechert 2015-05-20 12:46:26 -03:00
parent 3913267804
commit bb3b9c99a7
2 changed files with 28 additions and 9 deletions

View File

@ -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)
)

View File

@ -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: ""