Created
January 7, 2020 11:32
-
-
Save aprilandjan/4b302fcfa8477ea5c757bab3dcb1727b to your computer and use it in GitHub Desktop.
download-and-extract-npm-module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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