natgeo/activitystreams — pull request #11 by eli-taft-quoininc (2014-03-10 06:19:54+00:00)
Title: Sails Environment-Specific local.js Config

This pull request modifies local.js to allow for environment-specific configuration.

First, it defines defaults for 'port' and 'environment'. Port is the standard 1337 for fun. We override that and use 9365 in 'development', and perhaps it will be something else in production? To be determined. Environment is set to 'development' if not defined by process.env.NODE_ENV.

Second, it checks to see if there is an environment-specific config file located in /config/environments/. If environment is 'development', that means it's looking for 'config/environments/development.js'. It will then load those settings.

Thirdly, it checks for an optional file 'config/environments/myLocal.js'. This file is ignored in git and is only intended for cases where a local developer needs to override something for his environment but doesn't want to commit that. Like using another port.

*To Test*:

* When you run sails lift, the terminal output will indicate which environment it is running under.
* From the command line, run: "NODE_ENV='asdf' sails lift". This will basically demonstrate what sails will use if the environment isn't recognized. Port should be 1337, environment should be 'asdf'.
* From the command line, run "sails lift". When NODE_ENV isn't set, it should use development by default. Port should be 9365, environment should be 'development'.
* From the command line, run "NODE_ENV='production' sails lift". Port should be 9365, environment should be 'production'.
* Create a file config/environments/myLocal.js. Just put "module.exports = {port: 9366};" inside (without quotes). Then run "sails lift". The terminal output should indicate that sails is running on port 9366. Environment should be 'development' because it wasn't otherwise specified.