forked from HabitRPG/habitica-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
112 lines (93 loc) · 3.19 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
/*global module:false*/
module.exports = function(grunt) {
var fs = require('fs');
var core = [
'common/js/else/defaults.js',
'common/js/core/utilies.js',
'common/js/core/activators.js',
'common/js/core/sitewatcher.js',
'common/js/core/todos.js',
'common/js/core/tomatoes.js',
'common/js/core/pomodoroTracker.js',
'common/js/core/habitica.js'
];
// Project configuration.
grunt.initConfig({
jshint: {
opera: ['opera/*.js'],
safari: ['safari/*.js'],
chrome: ['chrome/*.js', 'common/js/else/*.js'],
firefox: ['firefox/*.js'],
core: core,
binds: ['common/js/binds/*.js'],
test: ['common/js/test/*/*.js']
},
concat: {
chrome: {
files: attachBindConcats('chrome', {
'builds/chrome/background.js': core.concat(['chrome/app.js']),
'builds/chrome/popup.js': ['chrome/popup.js', 'common/js/else/popup.js'],
'builds/chrome/options.js': ['common/js/else/defaults.js', 'common/js/else/options.js']
})
}
},
watch: {
core: {
files: core.concat(['common/js/test/core/*.js']),
tasks: 'test_core'
},
chrome: {
files: ['common/**', 'chrome/**'],
tasks: 'chrome'
},
chromeLint: {
files: ['common/**', 'chrome/**'],
tasks: ['jshint:core', 'jshint:chrome']
}
},
jasmine : {
core: {
src: core,
options: {
specs: ['common/js/test/core/utilies_test.js', 'common/js/test/core/activators_test.js', 'common/js/test/core/sitewatcher_test.js', 'common/js/test/core/habitica_test.js'],
timeout: 1000
}
}
},
clean: {
chrome: ['builds/chrome'],
test: ['_SpecRunner.html']
},
copy: {
chrome: {
files: [
{ src: ['common/img/*'], dest: 'builds/chrome/img/', expand: true, flatten: true },
{ src: ['common/css/*'], dest: 'builds/chrome/css/', expand: true, flatten: true },
{ src: ['common/js/vendor/*'], dest: 'builds/chrome/vendor/', expand: true, flatten: true },
{ src: ['common/html/*', 'chrome/data/*'], dest: 'builds/chrome/', expand: true, flatten: true },
{ src: ['node_modules/markdown/lib/markdown.js'], dest: 'builds/chrome/vendor/', expand: true, flatten: true },
]
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
// Tasks
grunt.registerTask('default', 'jshint');
grunt.registerTask('test_core', ['jshint:core', 'jshint:test', 'jasmine:core', 'clean:test']);
grunt.registerTask('chrome', [
'jshint:core', 'jshint:chrome', 'clean:chrome', 'copy:chrome', 'concat:chrome'
]);
function attachBindConcats(type, obj) {
files = fs.readdirSync('common/js/binds');
for (var i=0,len=files.length; i<len; i++) {
obj['builds/'+type+'/bind_'+files[i]] = [type+'/bind.js', 'common/js/binds/'+files[i]];
}
return obj;
}
};