[FEATURE] Make it easier to install several dependencies at once
ackvf opened this issue · comments
What / Why
Using
npx
to initiate project scaffolders is quite common and is actually the only reason I ever use npx. Such a scaffolder often needs more than one package installed though. I would appreciate if the syntax was a little bit leaner.
currently
npx -p yo -p generator-code -c "yo code"
desired
npx -c "yo code" -d yo generator-code
npx -c "<command-string>" -d <package>[ <package>]...
dependencies -d
-d <space-separated-packages-list>
is a shorthand for[-p <package>]...
- The
-d
option will interpret any<command>
after-d
as a package name until another<option>
is encountered
By the way, the -c
isn't needed, right? You can use just npx -p yo -p generator-code yo code
.
@felipecassiors I don't know, but in that case, the new preferred syntax would be
npx yo code -d yo generator-code
Just so that we are on the same track, imagine this
npx yo code -d yo generator-code promise-polyfill datetime module-loader typescript
which would be short for
npx yo code -p yo -p generator-code -p promise-polyfill -p datetime module-loader -p typescript
# Does not work
$ npx yo code -p yo -p generator-code
Error code -p yo -p generator-code
# Works
$ npx -p yo -p generator-code yo code
The reason is that everything from "yo" on is used to construct the command line to be executed.
How about instead changing -p
to take a comma delimited list?
# Concept: comma separated list
$ npx -p yo,generator-code@^1.2.10 yo code
The fact is that npx
treats any non-option argument as the command to run. And all the subsequent arguments to be passed as-is for the command. Just like docker run
. And this is not supposed to be changed.
I think accepting a comma-delimited list is the cleanest approach so far, as suggested by @docwhat.