carbon-design-system / stylelint-plugin-carbon-tokens

Apache License 2.0
9 stars 4 forks source link

Doesn't work on Windows #33

Closed s100 closed 2 years ago

s100 commented 3 years ago

initMotionTokens.js assumes that __dirname uses forward slashes, but on Windows it uses backslashes. This has the result that the constructed path layoutFile for accessing carbon-components/src/globals/scss/_motion.scss, on my machine, is:

'C:\\Users\\User\\Documents\\projects\\my-project\\node_modules\\stylelint-plugin-carbon-tokens\\node_modules\\carbon-components\\src\\globals\\scss\\_motion.scss'

when it should be:

'C:\\Users\\User\\Documents\\projects\\my-project\\node_modules\\carbon-components\\src\\globals\\scss\\_motion.scss'

This causes an ENOENT exception to be thrown and stylelint fails.

In general I think manual path parsing is a hazardous way to do this anyway - who's to say carbon-components is in the same node_modules directory as stylelint-plugin-carbon-tokens? It could be nested inside stylelint-plugin-carbon-tokens's own node_modules directory, or installed globally. I think a more robust approach would be to use Node.js's built-in require.resolve to figure out where the carbon-components package is on disk, and go from there.

s100 commented 2 years ago

Ran into this again today, any chance of addressing it? If this package is unmaintained we may just stop using it.

it-rec commented 2 years ago

@joshblack Do you have any insight for us on this repo?

lee-chase commented 2 years ago

Hey, @s100 for whatever reason I did not notice your message. However, I have made a number of recent updates.

The package no longer uses a path in this way and should not as a result fail as it was doing for you.

lee-chase commented 2 years ago

Closing due to inacitivety. Please re-open if still an issue.