Closed alexander-akait closed 7 years ago
@schnittstabil i make standard npm scripts
for fast build sites and sometimes any directories may empty and i got error, try to use cash-true
unstable and give error on some window
:cry:
Ah, of course cpy-cli … || true
doesn't help much, because cpy
may stop copying on first error.
@sindresorhus IMO a --null
option would be helpful in some cases, I would like to do implement it, if you agree:
--null If a pattern matches no paths, the pattern is ignored, rather than
used literally as path
About the naming: bash
calls this option nullglob
, thus --null-glob
also sounds appropriate.
/cc @sindresorhus
@schnittstabil Is there any way we can solve this without an option? If not, we at least need a clearer name than --null
.
Is there any way we can solve this without an option?
I'm afraid not, nonull: true
is reasonable for almost all interactive CLI sessions.
However, in npm scripts it's sometimes fine, that the patterns doesn't match any paths, but e.g. permission errors should still stop the build, thus cpy … || true
or similar doesn't help.
Naming alternatives:
--null-glob
because bash
naming is similar--ignore-missing
doesn't work very well, it sound like ENOENT
errors are ignored to me (e.g. because of race conditions)--ignore-???
, phew, maybe --ignore-no-match
, --ignore-empty-match
?@schnittstabil It's just slighty annoying as this sets a precedence that every tool that supports globbing would have to implement such option. You know I don't like options.
--ignore-no-match
sounds good.
It's just slighty annoying as this sets a precedence that every tool that supports globbing…
We might do it by means of globby and environment variables:
"copy": "GLOBBY_IGNORE_NO_MATCH=yes cpy …"
I don't know, whether that's such a good idea though.
@schnittstabil With https://www.npmjs.com/package/cross-env should work fine on all platforms, later tests this solution
@evilebottnawi globby
doesn't support it (yet) - this was just an idea…
@schnittstabil :disappointed:
For the sake of completeness, the default behavior was introduced by:
Therefore,
nonull
is already set totrue
at cli.js#L33.That said, I think the current behavior is reasonable for a CLI application. @evilebottnawi Can you give us some context, why this feature is useful for you?