-
Notifications
You must be signed in to change notification settings - Fork 2
/
gruntfile.js
117 lines (105 loc) · 3.39 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
114
115
116
117
module.exports = function(grunt) {
'use strict';
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-browserify');
grunt.initConfig({
jshint: {
browser: {
options: browserLintOptions(),
src: "src/client/*.js"
},
node: {
options: nodeLintOptions(),
src: ["src/*.js", "src/server/**/*.js", "*.js", "test/**/*.js"]
}
},
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js']
},
},
browserify: {
dist: {
files: {
'src/client/build/edit-team.js': ['src/client/main-edit-team.js'],
'src/client/build/all-teams.js': ['src/client/main-all-teams.js']
}
}
}
});
grunt.registerTask('default', ['clean', 'jshint', 'browserify', 'mochaTest']);
grunt.registerTask('clean', 'clean build folder', function() {
var fs = require('fs');
var path = 'src/client/build/';
fs.exists(path, function(exists) {
if(exists) {
fs.readdirSync(path).forEach(function(file,index) {
fs.unlink(path + file);
});
}
else {
fs.mkdir(path);
}
});
});
grunt.registerTask('watch', ['browserify', 'start-server']);
grunt.registerTask('start-server', 'starts the server', function() {
var done = this.async();
var server = require('./src/server/server.js');
server.start(function() {
grunt.log.write('server started');
});
});
grunt.registerTask('fake-100km', 'starts a fake 100km server', function() {
var done = this.async();
var fake_server = require('./test/fake_server.js');
grunt.log.write('server started');
});
grunt.registerTask('create-database', 'creates the database. WARNING: will drop all the data', function() {
var done = this.async();
var database = require('./src/server/database.js');
var utils = require('./src/server/utils.js');
var fs = require('fs');
fs.writeFile(utils.defaultOptions.logfilePath, "", function() {
database.createDB(utils.defaultOptions.databasePath, function() {
grunt.log.write('database created');
done();
});
});
});
function globalLintOptions() {
return {
bitwise: true,
curly: false,
eqeqeq: true,
forin: true,
immed: true,
latedef: false,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
regexp: true,
undef: true,
strict: true,
trailing: true,
multistr: true
};
}
function nodeLintOptions() {
var options = globalLintOptions();
options.node = true;
return options;
}
function browserLintOptions() {
var options = nodeLintOptions();
options.browser = true;
options.ignores = "src/client/build/**/*.js";
return options;
}
var DEFAULT_DB_PATH = './100km.sqlite';
};