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

Commit

Permalink
adding a grunt-contrib-copy dev dependency to create a local copy of …
Browse files Browse the repository at this point in the history
…local.js file and then updating config.js to include it and gruntfile.js to run it in all common tasks
  • Loading branch information
lirantal committed May 13, 2015
1 parent 0fc412d commit aca6a79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* Module dependencies.
*/
var _ = require('lodash'),
glob = require('glob');
glob = require('glob'),
fs = require('fs');

/**
* Load app configurations
*/
module.exports = _.extend(
require('./env/all'),
require('./env/' + process.env.NODE_ENV),
require('./env/local.js') || {}
(fs.existsSync('./config/env/local.js') && require('./env/local.js')) || {}
);

/**
Expand Down
19 changes: 15 additions & 4 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var fs = require('fs');

module.exports = function(grunt) {
// Unified Watch Object
var watchFiles = {
Expand Down Expand Up @@ -143,6 +145,15 @@ module.exports = function(grunt) {
unit: {
configFile: 'karma.conf.js'
}
},
copy: {
localConfig: {
src: 'config/env/development.js',
dest: 'config/env/local.js',
filter: function() {
return !fs.existsSync('config/env/local.js');
}
}
}
});

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

// Default task(s).
grunt.registerTask('default', ['lint', 'concurrent:default']);
grunt.registerTask('default', ['lint', 'copy:localConfig', 'concurrent:default']);

// Debug task.
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
grunt.registerTask('debug', ['lint', 'copy:localConfig', 'concurrent:debug']);

// Secure task(s).
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']);
grunt.registerTask('secure', ['env:secure', 'lint', 'copy:localConfig', 'concurrent:default']);

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

// Test task.
grunt.registerTask('test', ['test:server', 'test:client']);
grunt.registerTask('test', ['copy:localConfig', 'test:server', 'test:client']);
grunt.registerTask('test:server', ['env:test', 'mochaTest']);
grunt.registerTask('test:client', ['env:test', 'karma:unit']);
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"grunt-mocha-test": "~0.12.1",
"grunt-karma": "~0.9.0",
"load-grunt-tasks": "~1.0.0",
"grunt-contrib-copy": "0.8",
"karma": "~0.12.0",
"karma-jasmine": "~0.2.1",
"karma-coverage": "~0.2.0",
Expand Down

0 comments on commit aca6a79

Please sign in to comment.