Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Created November 7, 2023 19:57
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 amoilanen/b6bffdf75d4f8fa7e019a9165746dad0 to your computer and use it in GitHub Desktop.
Save amoilanen/b6bffdf75d4f8fa7e019a9165746dad0 to your computer and use it in GitHub Desktop.
Installs a local NPM package to a local project for testing purposes. Usage: npm_install_local_package package_dir project_dir
#!/bin/bash
if [ "$1" == "-h" ]; then
echo "Usage: `basename $0` npm_package_dir project_dir"
echo "Installs a local NPM package to a local project for test purposes"
exit 0
fi
PACKAGE_DIR=$1
REPO_DIR=$2
PACKAGE_DIR=$1
cd $PACKAGE_DIR
npm pack
echo "Found new package $PACKAGE_TAR"
PACKAGE_TAR=$(ls *.tgz)
mv $PACKAGE_DIR/$PACKAGE_TAR $REPO_DIR
cd $REPO_DIR
npm install $PACKAGE_TAR
rm $PACKAGE_TAR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment