New subcommand "npm clone"

I just got into this one situation that usually drives me (just a little bit) insane.
I am required to clone the source of a package, then afterwards I need to step into the directory to install the dependencies too.
I know this could be resolved with an alias command, but … maybe it’s time for a subcommand npm clone?
That way we could prepare a package for being worked on in a single utility command that may also have other useful options.

Cloning from a source

npm clone <packageName>

would go look into the repository configuration of packageName on the NPM registry (default, can be overridden with --registry as usual) and clones it from there with whatever program can be found that might make sense.

"type": "git" -> use git
"type": "svn" -> use whatever can handle that.

npm clone <URL>

would clone from the given URL and then do the same as above.

After cloning

Unless an option like --no-install is given, npm clone could then install the dependencies for that package or run a script!

Options

Option Meaning
-w / --work-dir Where to run the npm commands (such as npm install)
-r / --run A script to run after cloning
-n / --no-install No automatic install will be run

Examples

  • npm clone express -r test
    Clones the source of the express package and runs tests.
  • npm clone typescript -n
    Clones TypeScript from GitHub and then does nothing.
  • npm clone https://github.com/badges/shields -w gh-badges
    Clones the shields repository from GitHub and installs the dependencies of the gh-badges package in the gh-badges directory.

I am looking forward to feedbac and other ideas by you guys :slight_smile: