-
-
Save niktayv/c9d09b46c84ec3f9cb162c02fbbebe67 to your computer and use it in GitHub Desktop.
Script to bootstrap a nodejs project
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
| project_name=$1 | |
| project_description=$2 | |
| location=$HOME/code/$project_name | |
| pkg=$location/package.json | |
| readme=$location/readme.md | |
| node_version=$(node --version) | |
| npm_version=$(npm --version) | |
| if [ -z "$project_name" ]; then | |
| echo "Error: a project name must be provided." | |
| exit 1 | |
| fi | |
| echo "\n> Creating $location..." | |
| mkdir -p $location | |
| cd $location | |
| echo "Done!" | |
| echo "\n> Cloning template from simonrenoult/nodejs-project-template..." | |
| git clone [email protected]:simonrenoult/nodejs-project-template.git . | |
| rm -rf .git | |
| echo "Done!" | |
| echo "\n> Customizing template..." | |
| sed -i "s/{{name}}/$project_name/" $pkg $readme | |
| sed -i "s/{{node}}/$node_version/" $pkg $readme | |
| sed -i "s/{{npm}}/$npm_version/" $pkg $readme | |
| if [ -z "$project_description" ]; then | |
| sed -i "s/{{description}}/$project_description/" $pkg $readme | |
| else | |
| sed -i "s/{{description}}//" $pkg $readme | |
| fi | |
| echo "Done!" | |
| echo "\n> Installing NPM dependencies..." | |
| npm install | |
| git init | |
| git remote add origin [email protected]:simonrenoult/$project_name.git | |
| git add --all | |
| echo "Done!" | |
| echo "\n> Commiting everything..." | |
| git commit --message="Initial commit" | |
| echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment