-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
113 lines (105 loc) · 3.44 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
module.exports = function(grunt) {
/*Grab the configuration file (which is gitignored) to set the appropriate environmental variables and API Keys
Please Make Sure:
1)env.config.js is a javascript file or module.exports won't work
2)env.config.js is gitignored or our API keys will be publicly visible
*/
var localConfig;
try {
localConfig = require('./env.config');
} catch(e) {
localConfig = {};
}
grunt.initConfig({
karma: {
options: {
// point all tasks to karma config file
configFile: 'karma.conf.js'
},
unit: {
singleRun: true
},
continuous: {
// keep karma running in the background
background: true
},
travis: {
configFile: 'karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},
nodemon: {
dev: {
script: 'server/server.js'
}
},
shell: {
mongo: {
command: 'sudo mongod',
options: {
async: true
}
}
},
open : {
dev : {
path: 'http://localhost:3000/',
app: 'Google Chrome'
}
},
watch: {
karma: {
// run the continuous karma task when on file change
files: ['client/app/app.js','client/app/home/homeCtrl.js', 'Spec/unit/auth.js'],
tasks: ['karma:continuous:run']
}
},
env : {
dev : {
options: {},
NODE_ENV : 'development',
DEST : 'builds/dev'
},
build : {
NODE_ENV : 'production',
DEST : 'builds/production'
},
all: localConfig
}
});
// load the Grunt task
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-open');
//Server development
grunt.registerTask('server-dev', function (target) {
// Running nodejs in a different process and displaying output on the main console
var nodemon = grunt.util.spawn({
cmd: 'grunt',
grunt: true,
args: 'nodemon'
});
nodemon.stdout.pipe(process.stdout);
nodemon.stderr.pipe(process.stderr);
});
//will run our unit tests once and report the results in Karma
grunt.registerTask('unit-test', ['karma:unit']);
//Use development mode while working on our codebae, it will watch for any file changes and run karma continuously
grunt.registerTask('devmode', ['env:all','env:dev','printEnv','shell:mongo','server-dev','open:dev', 'karma:continuous:start', 'watch:karma']);
//Test is what Travis uses to run our test suite, it is initiated in the 'scripts' section in package.json
grunt.registerTask('test', ['karma:travis']);
//Task to check what current env variables are (useful for debugging)
grunt.registerTask('printEnv', 'prints a message with an env var', function() {
console.log('Gruntfile.js Environmental variables being set: ' + process.env.DEST, process.env);
});
/*These tasks will eventually be what we run for development and production, at the moment they are
just placeholders that print out the Node environmental variables
*/
grunt.registerTask('prod', ['env:all', 'env:build', 'printEnv']);
grunt.registerTask('dev', ['env:all', 'env:dev', 'printEnv']);
};