[bash script] 初始化一个 node.js 应用开发 working tree

#!/bin/bash

#
# filename: init.sh
#
# Generate working tree for node.js applicaiton project.
#
# version: 0.0.1 
#

exename="$(basename "$0")"
workdir="$(dirname "$0")"
#cd "$(dirname "$0")"

if [ x"$1" == x"" ]; then
	echo "Error, application name is required."
	echo "Usage: $exename <appname>"
	exit 1
fi

appname="$1"

echo -n "making project folder $appname ... "
mkdir $appname || {
	exit 1
}
cd $appname
echo "done"

echo -n "making working tree ... "
mkdir public
mkdir public/js
mkdir public/js/lib
mkdir public/js/views
mkdir public/styles
mkdir public/templates
mkdir views

touch app.js
touch public/js/lib/jquery.js
touch public/js/lib/require.js
touch public/js/views/index.js
touch public/styles/styles.css
touch public/templates/index.html
touch views/index.jade
echo "done"

echo -n "making project property file ... "
cat <<EOF > package.json
{
    "name": "$appname",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
      "express": "~3.0.0",
      "jade": ">= 0.0.1",
      "mongoose": ">= 2.6.5"
  }
}
EOF
echo "done"

# Using `npm install <node-module-name> --save` to install a node.js module and save as dependency in package.json




脚本随意命名为: init.sh

脚本内容:


你可能感兴趣的:(shell,node.js)