Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different glob behaviour on Windows and macOS #5236

Closed
davidgilbertson opened this issue Apr 7, 2021 · 1 comment
Closed

Different glob behaviour on Windows and macOS #5236

davidgilbertson opened this issue Apr 7, 2021 · 1 comment

Comments

@davidgilbertson
Copy link

Clearly describe the bug

Cannot get consistent glob behaviour across operating systems. I want to pass a glob, and not have the shell expand it.

What stylelint configuration is needed to reproduce the bug?

I can do this, as a script in package.json:

"lint": "stylelint src/**/*.css",

Which will appear to work, but silently misses a lot of files on Linux/macOS because that glob is expanded by the shell and ** is treated as *. But it works on Windows.

I can try using single quotes around the glob:

"lint": "stylelint 'src/**/*.css'",

Now it works on Linux/macOS, but fails on Windows because the actual string, with quote marks, is passed to stylelint, so argv looks like [ "'src/**/*.css'" ].

And I can't use double quotes because actually I'm running this with concurrently so double quotes would look like this, and then they get removed and I'm back to the shell expanding the glob incorrectly on Linux.

"lint": "concurrently \"stylelint \"src/**/*.css\"\"",

I can use a glob pattern that the shell doesn't recognise, and this is the only thing that behaves the same cross-OS.

"lint": "concurrently \"stylelint **/*.{css,nothing}\"",

But that's pretty nasty.

The cheap fix would be to check for file input strings that start and end in a single quote and remove the quote characters.

What do other people do, this seems like the sort of thing most people must face. Am I doing something dumb?

Which version of stylelint are you using?

13.8.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

npm script in package.json, with concurrently.

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

No

What did you expect to happen?

Consistent behaviour across macOS, Linux, and Windows. Or words in the docs explaining how to work around it.

What actually happened (e.g. what warnings or errors did you get)?

As above


I'm aware of these issues #4521 but couldn't see anything specifically about this issue.

@hudochenkov
Copy link
Member

Indeed, you need to use double quotes to have consistent glob matching across platforms.

For concurrently I would suggest using an additional npm script, otherwise it's too much double quotes and escaping:

"lint:styles": "stylelint \"src/**/*.css\"",
"lint": "concurrently \"npm run lint:styles\"",

@jeddy3 jeddy3 closed this as completed Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants