Created
May 26, 2016 15:27
-
-
Save nexdrew/8944bb8725edaaa72afa2509cd715d78 to your computer and use it in GitHub Desktop.
bash script to manually publish a public package to your private npm Enterprise registry
This file contains hidden or 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
#!/usr/bin/env bash | |
trap 'exit' ERR | |
for PACKAGE | |
do | |
echo "$PACKAGE" | |
# download and extract tarball for latest version | |
curl `npm info $PACKAGE dist.tarball --registry https://registry.npmjs.org` | tar xz | |
# run this script with NPME_REGISTRY=http://reg.myco.com:8080 | |
# or make sure ~/.npmrc points to your private registry by default | |
if [[ "x$NPME_REGISTRY" != "x" ]] | |
then | |
npm publish package --ignore-scripts --registry $NPME_REGISTRY | |
else | |
npm publish package --ignore-scripts | |
fi | |
# cleanup extracted tarball contents | |
rm -rf package | |
done | |
echo "success!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI: npm can publish a tarball directly, so you can skip unpacking it just to have npm immediately pack it again. Also the
npm pack
command can download a package for you, and helpfully dumps the filename that it downloaded to stdout: