wongjn / vscode-php-sniffer

Visual Studio Code extension for PHP_Codesniffer validation and formatting.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
MIT License
46 stars 7 forks source link

executablesFolder setting requires different values for windows and unix. #54

Closed x-user closed 6 months ago

x-user commented 3 years ago

Describe the bug Setting executablesFolder with unix path separator doesn't work on windows.

To Reproduce

  1. install squizlabs/PHP_CodeSniffer in project sub folder.
  2. set executablesFolder in project settings using unix path separator (ex: tools/phpcs/vendor/bin).
  3. Open project on windows machine.

Expected behavior For the executables path setting to work without modification.

Environment

Extension settings

{
  "phpSniffer.executablesFolder": "tools/phpcs/vendor/bin"
}

Additional context Error message

"tools" is not recognized as an internal or external command, operable program or batch file.

While platform specific settings isn't implemented in VSCode there two possible solutions:

  1. Use path.normalize (as in psalm/psalm-vscode-plugin)
  2. Add separate settings for windows (as in junstyle/vscode-php-cs-fixer)
jonshipman commented 6 months ago

You can use the VSCode variable ${pathSeparator}

{
  "phpSniffer.executablesFolder": "tools${pathSeparator}phpcs${pathSeparator}vendor${pathSeparator}bin"
}
x-user commented 6 months ago

You can use the VSCode variable ${pathSeparator}

{
  "phpSniffer.executablesFolder": "tools${pathSeparator}phpcs${pathSeparator}vendor${pathSeparator}bin"
}
{
  "phpSniffer.executablesFolder": "tools${/}phpcs${/}vendor${/}bin"
}

I forgot about this long time ago, thank you for reminder. I didn't know if path separator variable existed when i created this issue, but now it even have this short alias ${/}, closing.