Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1011 from mleanos/mongoose-4.1.12-connect-bug
Browse files Browse the repository at this point in the history
feat(config): Local environment configurations
  • Loading branch information
lirantal committed Dec 2, 2015
2 parents e03cae9 + 6d74474 commit 43c7041
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public/dist/
uploads
modules/users/client/img/profile/uploads
config/env/local.js
config/env/local-*.js
*.pem

# Ignoring MEAN.JS's gh-pages branch for documenation
Expand Down
8 changes: 2 additions & 6 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,8 @@ var initGlobalConfig = function () {
var pkg = require(path.resolve('./package.json'));
config.meanjs = pkg;

// We only extend the config object with the local.js custom/local environment if we are on
// production or development environment. If test environment is used we don't merge it with local.js
// to avoid running test suites on a prod/dev environment (which delete records and make modifications)
if (process.env.NODE_ENV !== 'test') {
config = _.merge(config, (fs.existsSync(path.join(process.cwd(), 'config/env/local.js')) && require(path.join(process.cwd(), 'config/env/local.js'))) || {});
}
// Extend the config object with the local-NODE_ENV.js custom/local environment. This will override any settings present in the local configuration.
config = _.merge(config, (fs.existsSync(path.join(process.cwd(), 'config/env/local-' + process.env.NODE_ENV + '.js')) && require(path.join(process.cwd(), 'config/env/local-' + process.env.NODE_ENV + '.js'))) || {});

// Initialize global globbed files
initGlobalConfigFiles(config, assets);
Expand Down
15 changes: 13 additions & 2 deletions config/env/local.example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
'use strict';

// Rename this file to local.js for having a local configuration variables that
// Rename this file to local-NODE_ENV.js (i.e. local-development.js, or local-test.js) for having a local configuration variables that
// will not get commited and pushed to remote repositories.
// Use it for your API keys, passwords, etc.

/* For example:
// WARNING: When using this example for multiple NODE_ENV's concurrently, make sure you update the 'db' settings appropriately.
// You do not want to accidentally overwrite/lose any data. For instance, if you create a file for 'test' and don't change the
// database name in the setting below, running the tests will drop all the data from the specified database.
//
// You may end up with a list of files, that will be used with their corresponding NODE_ENV:
//
// local-development.js
// local-test.js
// local-production.js
//

/* For example (Development):
module.exports = {
db: {
Expand Down
4 changes: 2 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ module.exports = function (grunt) {
copy: {
localConfig: {
src: 'config/env/local.example.js',
dest: 'config/env/local.js',
dest: 'config/env/local-development.js',
filter: function () {
return !fs.existsSync('config/env/local.js');
return !fs.existsSync('config/env/local-development.js');
}
}
}
Expand Down

0 comments on commit 43c7041

Please sign in to comment.