Skip to content

Commit 67e8460

Browse files
committed
Simplified setup by moving sql into its own script
1 parent c289735 commit 67e8460

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ This is the repo for the JavaScript.com website.
44

55
## Installing NVM
66

7-
- Install NVM (`$ brew install nvm` and follow instructions)
8-
- `$ nvm install iojs-v1.2.0`
9-
- `$ nvm use iojs-v1.2.0`
7+
Install NVM (`$ brew install nvm` and follow instructions)
8+
9+
```bash
10+
nvm install iojs-v1.2.0
11+
nvm use iojs-v1.2.0
12+
npm install -g gulp
13+
npm install
14+
```
15+
16+
This app authenticates with GitHub, so you'll need to create a GitHub Application and set ENVs for `GH_CLIENT_ID` and `GH_CLIENT_SECRET`.
1017

1118
## Running
1219

13-
* Install dependencies with `$ npm install`.
14-
* Create the local PostgreSQL database with `$ createdb javascriptcom`.
15-
* Load schema with `$ psql javascriptcom < db/schema.sql`
16-
* This app authenticates with GitHub, so you'll need to create a GitHub Application and set ENVs for `GH_CLIENT_ID` and `GH_CLIENT_SECRET`.
17-
* Run the application with `$ npm start`.
18-
* Compile and watch Sass with `$ gulp`.
20+
Run the application with `$ npm start`. You can also set the environment variables at start time. Here's an example:
21+
22+
```bash
23+
$ GH_CLIENT_ID=myid GH_CLIENT_SECRET=mysecret npm start
24+
```
25+
Compile and watch Sass with `$ gulp`.
1926

2027
For debugging all the things, run `DEBUG=* npm start`.
2128

db/setup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# How do we only run this if the javascriptcom database doesn't exist?
2+
3+
if psql javascriptcom -c '\q' 2>&1
4+
then
5+
# The database exists
6+
echo "javascriptcom database already loaded"
7+
else
8+
createdb javascriptcom
9+
psql javascriptcom < db/schema.sql
10+
fi
11+

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"iojs": "1.2.0"
77
},
88
"scripts": {
9-
"start": "node --harmony_object_literals ./bin/www"
9+
"start": "node --harmony_object_literals ./bin/www",
10+
"postinstall": "./db/setup.sh"
1011
},
1112
"dependencies": {
1213
"body-parser": "~1.10.2",

0 commit comments

Comments
 (0)