-
-
Notifications
You must be signed in to change notification settings - Fork 38
Globs on Windows PowerShell not working correctly? #84
Comments
I've tried different the following variations of the glob to see if it might be related to that:
But I get the same error |
Forgot to mention, that if I change the |
Ok, this actually seems to be an issue with Windows not properly supporting globs - at least when npm scripts are involved. Tools like eslint are getting around this problem by using node-glob to parse the path, which means the developer should supply it like a string instead to be cross platform:
For more info see: |
A note on the use of As dependency-check itself doesn't do any or support any globbing today, but instead rather support an input format that's compatible with the shells own globbing support, I'm not sure how to best solve this. Ideally it could be solved independently of this module, but from the articles you link I get the feeling that it's not really a possibility? |
Yes, it seems that this is an issue that tools like eslint and the like have all encountered and the preferred solution seems to be to resolve globs manually inside the module instead of relying on the OS to do it as this unfortunately doesn't work reliably across different OS'es/shells (e.g. zsh vs bash vs PowerShell). If there is an external way to do this that would of course be better, but so far I haven't found one. |
I guess one possibility could be to accept the list of files from stdin in addition to the current way? So one can resolve the file list through another tool and then just pipe it to this one? But it would be somewhat unorthodox and break against the pattern established by ESLint etc so maybe we should just implement globbing internally. I'll have to think this through from my side. Any thoughts @blakeembrey @maxogden? |
It seems you can use this tool: https://www.npmjs.com/package/glob-cli2 If Windows support something similar to backticks from Linux then you could even run:
If not, you can use stdin as you suggested:
|
@watson One thought – maybe you can save the result of I often use an npm-script like this: JS_FILES="*.js lib/*.js" && dependency-check . $JS_FILES && dependency-check . $JS_FILES --unused --no-dev Perhaps that would be doable in PowerShell as well? Looks like it: https://stackoverflow.com/questions/8097354/how-do-i-capture-the-output-into-a-variable-from-an-external-process-in-powershe |
@voxpelli |
@watson Well, it does work on macOS and Linux and the intention of my script is mostly to share the glob between the two rather than to have it only be interpreted just once. But I'm not thinking that you would do exactly that, but rather have something evolve so that |
I think reason it works for you is not that it expands the glob into But the whole issue unfortunately is that expanding globs are very shell depended and assigning them to environment variables is as well. So coming up with a native shell command that works the same across shells is close to impossible I would guess. |
@watson This should work for you: JS_FILES=$(glob 'lib/instrumentation/modules/*') && dependency-check . $JS_FILES --unused --no-dev It runs (An unrelated thing: Also add |
To the best of my Google abilities, there's no way to construct a command like |
Tools like If not, I'll take a stab at implementing it. |
[dependecy-check](https://www.npmjs.com/package/dependency-check) version 3.2.0 was just released today with a fix for dependency-check-team/dependency-check#84 Fixes #199
Still seeing this issue on windows:
Any ideas? |
I'm trying to run the following command in Windows PowerShell:
But I get the following error:
The text was updated successfully, but these errors were encountered: