Skip to content

Detect phpcs version and add option --no-patch if version 2.*#16

Open
averagegeek wants to merge 1 commit intosoderlind:masterfrom
averagegeek:phpcs-2-no-patch
Open

Detect phpcs version and add option --no-patch if version 2.*#16
averagegeek wants to merge 1 commit intosoderlind:masterfrom
averagegeek:phpcs-2-no-patch

Conversation

@averagegeek
Copy link

@averagegeek averagegeek commented Mar 15, 2018

Ran into this issue, here is a proposition for a fix:

The extension does not work with phpcs 2.* on macos (haven't tried other operating systems) at the moment because by default, phpcs tries to write a .diff file in the current working directory. On macos, php is getting / as working directory and obviously can't write the diff file and fail with an error. Passing in the working directory when calling the phpcbf command fixes the issue.

Also the file argument is now added at the very end of the arguments and the console.group() and console.groupEnd() calls were replaced as those methods don't exists in node and trigger errors.

@jyrkih
Copy link

jyrkih commented Mar 28, 2018

I encountered the same issue, but found out that by giving an options parameter with a cwd property solves the issue. Ie:

let options = {
  cwd: TmpDir
}
let exec = cp.spawn(this.executablePath, this.getArgs(fileName), options);

@averagegeek
Copy link
Author

Yup, you're absolutely right and it's a better solution than checking for the version. Didn't knew you could pass in the working directory that way :)

the phpcbf command so reports can be generated properly
and replacing the console.group() and console.groupEnd()
with console.log() because those don't exists in node and
trigger errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants