-
Notifications
You must be signed in to change notification settings - Fork 2
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
Glob gets different results depending on where it’s launched #12
Comments
The glob is interpreted by the shell before it is processed by w3c-html-validator. The expanded command may be so long that in some situations files are getting dropped. However, w3c-html-validator will recursively search a folder for HTML files automatically, so maybe (hopefully) this issue is moot. What happens if you replace |
It works with all 42 files in both cases when just the |
I'm encountering a similar issue with globbing and can probably shed some light on this.
The recommendation from a number of other packages is to quote the glob pattern. This would work, except that line 39 and 40 of In my situation a large number of my files do not have an Ideally support for both folder and/or glob patterns would be good. What if a PR were created to add a command line option to override the default glob pattern? Would this likely be accepted as a concept? |
While w3c-html-validator uses globs internally, it currently does not explicitly support globs passed in when quoted. Glob is only used on folders so there's no risk of appending Adding explicit glob support (for quoted glob parameters) makes sense. Passing all the files through Maybe something like this: const globOptions = { ignore: '**/node_modules/**/*' };
const getFilenames = () =>
files.map(file => globSync(file, globOptions)).flat().map(expandFolder).flat().filter(keep).sort();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ first round of processing I suspect a new CLI option is not needed. Although, it is interesting that the popular rimraf project added a A PR would be great. |
Thank you for helping to figure out the multiple ignore messages in #11, it worked!
But then I noticed that the tool behaves differently with identical parameters. The only difference is where I launch it: via npm script or via npx in CLI.
Npm script
I have a script that goes like this:
And the tool is in the dependencies, of course:
But it sees only 4 files with the
dist/**/*.html
mask:Npx launch
But when I use exactly the same set of parameters via npx, it sees all 42 files (which is correct):
I’d love to use it via npm scripts, but I’m not sure why the same
dist/**/*.html
glob gives me different results. I tried some variations, but no luck so far.It’s macOS 13.5.2, Node v18.17.1, npm 9.6.7 (but I got the same results with Node v16)
The text was updated successfully, but these errors were encountered: