Skip to content

Instantly share code, notes, and snippets.

@tomfa
Created May 21, 2021 22:23
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 tomfa/259e3903e924ec64b32aa48e317cd07d to your computer and use it in GitHub Desktop.
Save tomfa/259e3903e924ec64b32aa48e317cd07d to your computer and use it in GitHub Desktop.
Bash script to start any node project.
install() {
if test -f "package.json"; then
if test -f "package-lock.json"; then
npm install
elif test -f "yarn.lock"; then
yarn
else
echo "warning: no lock file"
yarn
fi
else
echo "Missing package.json"
fi
}
alias ins=install
start() {
if test -f "package.json"; then
if grep -q "\"dev\"" "package.json"; then
yarn dev
elif grep -q "\"start:dev\"" "package.json"; then
yarn start:dev
elif grep -q "\"start:all\"" "package.json"; then
yarn start:all
else
yarn start
fi
else
echo "Missing package.json"
fi
}
alias sta=start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment