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

Commit aca6a79

Browse files
committed
adding a grunt-contrib-copy dev dependency to create a local copy of local.js file and then updating config.js to include it and gruntfile.js to run it in all common tasks
1 parent 0fc412d commit aca6a79

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

config/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
* Module dependencies.
55
*/
66
var _ = require('lodash'),
7-
glob = require('glob');
7+
glob = require('glob'),
8+
fs = require('fs');
89

910
/**
1011
* Load app configurations
1112
*/
1213
module.exports = _.extend(
1314
require('./env/all'),
1415
require('./env/' + process.env.NODE_ENV),
15-
require('./env/local.js') || {}
16+
(fs.existsSync('./config/env/local.js') && require('./env/local.js')) || {}
1617
);
1718

1819
/**

gruntfile.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var fs = require('fs');
4+
35
module.exports = function(grunt) {
46
// Unified Watch Object
57
var watchFiles = {
@@ -143,6 +145,15 @@ module.exports = function(grunt) {
143145
unit: {
144146
configFile: 'karma.conf.js'
145147
}
148+
},
149+
copy: {
150+
localConfig: {
151+
src: 'config/env/development.js',
152+
dest: 'config/env/local.js',
153+
filter: function() {
154+
return !fs.existsSync('config/env/local.js');
155+
}
156+
}
146157
}
147158
});
148159

@@ -162,13 +173,13 @@ module.exports = function(grunt) {
162173
});
163174

164175
// Default task(s).
165-
grunt.registerTask('default', ['lint', 'concurrent:default']);
176+
grunt.registerTask('default', ['lint', 'copy:localConfig', 'concurrent:default']);
166177

167178
// Debug task.
168-
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
179+
grunt.registerTask('debug', ['lint', 'copy:localConfig', 'concurrent:debug']);
169180

170181
// Secure task(s).
171-
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']);
182+
grunt.registerTask('secure', ['env:secure', 'lint', 'copy:localConfig', 'concurrent:default']);
172183

173184
// Lint task(s).
174185
grunt.registerTask('lint', ['jshint', 'csslint']);
@@ -177,7 +188,7 @@ module.exports = function(grunt) {
177188
grunt.registerTask('build', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'cssmin']);
178189

179190
// Test task.
180-
grunt.registerTask('test', ['test:server', 'test:client']);
191+
grunt.registerTask('test', ['copy:localConfig', 'test:server', 'test:client']);
181192
grunt.registerTask('test:server', ['env:test', 'mochaTest']);
182193
grunt.registerTask('test:client', ['env:test', 'karma:unit']);
183194
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"grunt-mocha-test": "~0.12.1",
6464
"grunt-karma": "~0.9.0",
6565
"load-grunt-tasks": "~1.0.0",
66+
"grunt-contrib-copy": "0.8",
6667
"karma": "~0.12.0",
6768
"karma-jasmine": "~0.2.1",
6869
"karma-coverage": "~0.2.0",

0 commit comments

Comments
 (0)