-
Notifications
You must be signed in to change notification settings - Fork 6
Fix reldir #11
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
base: master
Are you sure you want to change the base?
Fix reldir #11
Conversation
- Should match all until reaching * (so [^\*])
- fixed the tests. Because they were not pure. Before applying my changes. You run once it succeed. you run another it fail. Its random. - The supposition that the files are processed in a sorted manner is wrong. - glob package does have them alphabetically sorted. While listr package task runner. Does screw that. - To fix the issue. I opted for tests without relying on order. - More details on PR danielkalen#11 , fix of issue danielkalen#10 - Updated the tests of placeholders. To reflect the new changes.
Status: Doesn’t work for Windows ❌ 1. Summary@MohamedLamineAllal, foreach-cli — is cross-platform. Your changes don’t work on Windows. Please fix it. 2. MCVE2.1. Directory structure2.1.1. Initial
All 2.1.2. Desired
This structure can be obtained by running the commands: # [INFO] Stylus CLI usage:
# https://stylus-lang.com/docs/executable.html#compiling-files-example
- stylus output/theme/stylus/KiraFirstFolder/KiraFirstFile.styl --out output/theme/css/KiraFirstFolder/KiraFirstFile.css
- stylus output/theme/stylus/KiraSecondFolder/KiraSecondFile.styl --out output/theme/css/KiraSecondFolder/KiraSecondFile.css
- stylus output/theme/stylus/KiraSecondFolder/KiraSubfolder/KiraThirdFile.styl --out output/theme/css/KiraSecondFolder/KiraSubfolder/KiraThirdFile.css 2.2. CommandAs I understand from issue #10 and from your Medium article “Npm scripts - running commands with globs expansion for each file”, the command to get the desired directory structure should be like this:
2.3. Behavior2.3.1. Expected — Ubuntu
2.3.2. Unexpected — Windowsforeach --glob "output/theme/stylus/**/*.styl" --execute "stylus #{path} --out output/theme/css/#{reldir}/#{name}.css"
× Executing command: output/theme/stylus/KiraFirstFolder/KiraFirstFile.styl
× Executing command: output/theme/stylus/KiraSecondFolder/KiraSecondFile.styl
× Executing command: output/theme/stylus/KiraSecondFolder/KiraSubfolder/KiraThirdFile.styl
Error output/theme/stylus/KiraSecondFolder/KiraSecondFile.styl
node:fs:1374
const result = binding.mkdir(
^
Error: ENOENT: no such file or directory, mkdir 'C:\projects\sashatravis\output\theme\css\C:\projects\sashatravis\output\theme\stylus\KiraSecondFolder'
at mkdirSync (node:fs:1374:26)
at writeFile (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:738:3)
at Array.<anonymous> (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:687:13)
at Renderer.render (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\lib\renderer.js:98:29)
at C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:678:15
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\projects\\sashatravis\\output\\theme\\css\\C:\\projects\\sashatravis\\output\\theme\\stylus\\KiraSecondFolder'
}
Node.js v21.6.1
Error output/theme/stylus/KiraFirstFolder/KiraFirstFile.styl
node:fs:1374
const result = binding.mkdir(
^
Error: ENOENT: no such file or directory, mkdir 'C:\projects\sashatravis\output\theme\css\C:\projects\sashatravis\output\theme\stylus\KiraFirstFolder'
at mkdirSync (node:fs:1374:26)
at writeFile (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:738:3)
at Array.<anonymous> (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:687:13)
at Renderer.render (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\lib\renderer.js:98:29)
at C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:678:15
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\projects\\sashatravis\\output\\theme\\css\\C:\\projects\\sashatravis\\output\\theme\\stylus\\KiraFirstFolder'
}
Node.js v21.6.1
Error output/theme/stylus/KiraSecondFolder/KiraSubfolder/KiraThirdFile.styl
node:fs:1374
const result = binding.mkdir(
^
Error: ENOENT: no such file or directory, mkdir 'C:\projects\sashatravis\output\theme\css\C:\projects\sashatravis\output\theme\stylus\KiraSecondFolder\KiraSubfolder'
at mkdirSync (node:fs:1374:26)
at writeFile (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:738:3)
at Array.<anonymous> (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:687:13)
at Renderer.render (C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\lib\renderer.js:98:29)
at C:\Users\appveyor\AppData\Roaming\npm\node_modules\stylus\bin\stylus:678:15
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\projects\\sashatravis\\output\\theme\\css\\C:\\projects\\sashatravis\\output\\theme\\stylus\\KiraSecondFolder\\KiraSubfolder'
}
Node.js v21.6.1 2.4. DetailsYou can see more details about my MCVE in CI builds:
Thanks. |
Fix issue #10
Fix
reldir
not working as it say in the docTests
update + fix: tests
Fixing the tests
The supposition that the files are processed in a sorted manner is wrong.
The
glob
package does have them alphabetically sorted. Whilelistr
package task runner. Does screw that. (I logged glob matched files. it's always coming in a sorted manner. And always the same. And listr when does run it, the order is not guaranteed.)To fix the issue. I opted for tests without relying on order.
The were two cases
the placeholders, where i need to check against the output list of all placeholders. For this i built a parser. That construct a map by path. I checked and tested that all the paths that are tested are part of the result. So the paths are checked correctly. Then for every path. I use the map to rigorously and without having to rely on any order. Now the tests are pure. And fully stable
▫️ Rest of checks
to
Updating the test for placeholders