-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
98 lines (88 loc) · 3.36 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
var config = require('./app/config.js');
var fs = require('fs');
var moment = require('moment');
var envify = require('envify/custom');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
forever: {
server: {
options: {
index: 'app/server.js',
logDir: 'logs',
errFile: 'server_' + moment().format('DD_MM_YYYY') + '_err.txt',
outFile: 'server_' + moment().format('DD_MM_YYYY') + '_out.txt'
}
},
overlay: {
options: {
index: 'app/overlay_server.js',
logDir: 'logs',
errFile: 'overlay_' + moment().format('DD_MM_YYYY') + '_err.txt',
outFile: 'overlay_' + moment().format('DD_MM_YYYY') + '_out.txt'
}
}
},
watch: {
overlayDataFiles: {
files: [ 'overlay/**/*', '!overlay/overlay_compiled.js' ],
tasks: [ 'browserify:overlay' ]
},
overlayCompiled: {
files: [ 'overlay/overlay_compiled.js' ],
tasks: [ 'overlayForceReload' ]
},
overlayServer: {
files: [ 'app/overlay_server.js' ],
tasks: [ 'forever:overlay:restart' ]
},
server: {
files: [ 'app/*.ahk', 'app/*.js', '!app/overlay_server.js' ],
tasks: [ 'forever:server:restart' ]
}
},
browserify: {
overlay: {
src: 'overlay/overlay.js',
dest: 'overlay/overlay_compiled.js',
options: {
transform: [envify({
OVERLAY_HOST: config.overlayHost,
OVERLAY_PORT: config.overlayPort
})]
}
}
},
concurrent: {
servers: {
tasks: [ 'forever:server:start', 'forever:overlay:start', 'watch:overlayDataFiles', 'watch:overlayCompiled', 'watch:overlayServer', 'watch:server' ],
options: {
logConcurrentOutput: true,
limit: 10
}
},
overlayOnly: {
tasks: [ 'forever:overlay:start', 'watch:overlayDataFiles', 'watch:overlayCompiled', 'watch:overlayServer' ],
options: {
logConcurrentOutput: true,
limit: 10
}
},
serverOnly: {
tasks: [ 'forever:server:start', 'watch:server' ],
options: {
logConcurrentOutput: true
}
}
}
});
grunt.registerTask('listen', [ 'browserify:overlay', 'concurrent:servers' ]);
grunt.registerTask('server', [ 'concurrent:serverOnly' ]);
grunt.registerTask('overlay', [ 'browserify:overlay', 'concurrent:overlayOnly' ]);
grunt.registerTask('kill-server', [ 'forever:server:stop' ]);
grunt.registerTask('kill-overlay', [ 'forever:overlay:stop' ]);
grunt.registerTask('kill-all', [ 'forever:server:stop', 'forever:overlay:stop' ]);
grunt.registerTask('overlayForceReload', function () {
fs.writeFileSync('./temp/overlayReload', 'reload');
});
};