Skip to content

Instantly share code, notes, and snippets.

@aprilandjan
Created January 7, 2020 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprilandjan/4b302fcfa8477ea5c757bab3dcb1727b to your computer and use it in GitHub Desktop.
Save aprilandjan/4b302fcfa8477ea5c757bab3dcb1727b to your computer and use it in GitHub Desktop.
download-and-extract-npm-module
const exec = require('child_process').execSync;
const path = require('path');
module.exports = ({registry, pkgName, pkgVersion, cwd = process.cwd()}) => {
const url = `${registry}/${pkgName}/download/${pkgName}-${pkgVersion}.tgz`;
exec(`echo ${url} | xargs curl | tar -xz`, {
cwd,
});
return path.join(cwd, 'package');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment