Skip to content

Instantly share code, notes, and snippets.

@dittmaraz
Created August 25, 2019 05:17
Show Gist options
  • Save dittmaraz/ee1c1fb45a65006836d5036d2bed6667 to your computer and use it in GitHub Desktop.
Save dittmaraz/ee1c1fb45a65006836d5036d2bed6667 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Invalid argument count, expected: 1"
usage()
exit
fi
PRJNAME="$1"
echo "Project name set to: $PRJNAME"
mkdir -p "$PRJNAME"
cd "$PRJNAME"
npm init -y
read -p "Enter packages, comma-delimited[ENTER for none]: " PKGS
PKGS="$(echo -e "${PKGS}" | tr -d '[:space:]')" # Trim whitespace
PKGSARR=$(echo $PKGS|tr "," "\n")
for PKG in $PKGSARR
do
npm i -S "$PKG"
done
usage() {
echo "Usage: mkprj.sh <projectname>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment