I'm curious if anyone thinks adding glob support to core would be a good idea?
Globs (globspecs? what's the right term?) are natively supported in POSIX (?) shells, which means you can do this:
$ some-cli-app **/*.foo.js
This is expanded by the shell before execution of some-cli-app into a list of files matching the glob.
But we get in to trouble when our scripts (e.g., in package.json) use globs, because they will not be expanded, and the scripts will fail (or otherwise exhibit unexpected behavior) on Windows.
To support globs in a portable way, any CLI app would need to pull in glob or a similar module, and pass the glob as a quoted string in the arguments:
$ some-cli-app "**/*.foo.js"
(On Windows, you must use double-quotes above, but using single-quotes in POSIX shells means env variables [e.g., $FOO] will be treated as literals; env variables are another can of worms)
The utility of glob has been well-established, and it's used in enough CLI apps that it may be a good candidate for vendoring or some other implementation. I haven't looked at the glob source, so it's unclear whether vendoring would be the best route, but I do know it contains several other dependencies which would also need to be pulled in (right @iansu?).
Thoughts?
cc @isaacs
I'm curious if anyone thinks adding glob support to core would be a good idea?
Globs (globspecs? what's the right term?) are natively supported in POSIX (?) shells, which means you can do this:
This is expanded by the shell before execution of
some-cli-appinto a list of files matching the glob.But we get in to trouble when our scripts (e.g., in
package.json) use globs, because they will not be expanded, and the scripts will fail (or otherwise exhibit unexpected behavior) on Windows.To support globs in a portable way, any CLI app would need to pull in
globor a similar module, and pass the glob as a quoted string in the arguments:$ some-cli-app "**/*.foo.js"(On Windows, you must use double-quotes above, but using single-quotes in POSIX shells means env variables [e.g.,
$FOO] will be treated as literals; env variables are another can of worms)The utility of
globhas been well-established, and it's used in enough CLI apps that it may be a good candidate for vendoring or some other implementation. I haven't looked at theglobsource, so it's unclear whether vendoring would be the best route, but I do know it contains several other dependencies which would also need to be pulled in (right @iansu?).Thoughts?
cc @isaacs