Skip to content

Commit

Permalink
Merge pull request #2129 from Glavin001/bugfix/php-cs-fixer-docker
Browse files Browse the repository at this point in the history
Fix Docker Executable with optional Executable, PHP-CS-Fixer
  • Loading branch information
stevenzeck authored May 14, 2018
2 parents 7b3bc35 + efabda3 commit 5eb7e6d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Next

# v0.32.3 (2018-05-14)
- Issue [#448](https://github.com/Glavin001/atom-beautify/issues/448) Add support for Laravel Blade templates (beta)
- Fix Docker Executable with optional Executable, PHP-CS-Fixer ([#2129](https://github.com/Glavin001/atom-beautify/pull/2129))

# v0.32.2 (2018-03-10)
- Revert fix package.json repository field (#2062)
Expand Down
36 changes: 26 additions & 10 deletions src/beautifiers/executable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Executable
.then(() => @)
.catch((error) =>
if not @.required
@verbose("Not required")
@
else
Promise.reject(error)
Expand Down Expand Up @@ -366,6 +367,7 @@ class HybridExecutable extends Executable

constructor: (options) ->
super(options)
@verbose("HybridExecutable Options", options)
if options.docker?
@dockerOptions = Object.assign({}, @dockerOptions, options.docker)
@docker = @constructor.dockerExecutable()
Expand All @@ -389,18 +391,32 @@ class HybridExecutable extends Executable
super()
.catch((error) =>
return Promise.reject(error) if not @docker?
@docker.init()
.then(=> @runImage(@versionArgs, @versionRunOptions))
.then((text) => @saveVersion(text))
.then(() => @installedWithDocker = true)
.then(=> @)
.catch((dockerError) =>
@debug(dockerError)
Promise.reject(error)
)
return @
)
.then(() =>
shouldTryWithDocker = not @isInstalled and @docker?
@verbose("Executable shouldTryWithDocker", shouldTryWithDocker, @isInstalled, @docker?)
if shouldTryWithDocker
return @initDocker()
return @
)

initDocker: () ->
@docker.init()
.then(=> @runImage(@versionArgs, @versionRunOptions))
.then((text) => @saveVersion(text))
.then(() => @installedWithDocker = true)
.then(=> @)
.catch((dockerError) =>
@debug(dockerError)
Promise.reject(error)
)

run: (args, options = {}) ->
@verbose("Running HybridExecutable")
@verbose("installedWithDocker", @installedWithDocker)
@verbose("docker", @docker)
@verbose("docker.isInstalled", @docker and @docker.isInstalled)
if @installedWithDocker and @docker and @docker.isInstalled
return @runImage(args, options)
super(args, options)
Expand Down Expand Up @@ -430,7 +446,7 @@ class HybridExecutable extends Executable
image,
newArgs
],
options
Object.assign({}, options, { cmd: undefined })
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/beautifiers/php-cs-fixer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = class PHPCSFixer extends Beautifier
isPhpScript = (finalPhpCsFixerPath.indexOf(".phar") isnt -1) or (finalPhpCsFixerPath.indexOf(".php") isnt -1)
@verbose('isPhpScript', isPhpScript)

if finalPhpCsFixerPath and isPhpScript
if not phpCsFixer.isInstalled and finalPhpCsFixerPath and isPhpScript
php.run([finalPhpCsFixerPath, phpCsFixerOptions, tempFile], runOptions)
.then(=>
@readFile(tempFile)
Expand Down

0 comments on commit 5eb7e6d

Please sign in to comment.