-
Notifications
You must be signed in to change notification settings - Fork 142
/
Gruntfile.js
161 lines (147 loc) · 4.68 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
module.exports = function (grunt) {
'use strict';
// Project configuration.
var saucekey = process.env.saucekey;
if (!saucekey) {
console.warn('Unable to load Saucelabs key');
}
grunt.initConfig({
jade: {
release: {
files: {
'tests/index.html': ['tests/views/index.jade']
}
}
},
clean: ['tests/index.html'],
connect: {
server: {
options: {
base: '.',
port: 9999
}
}
},
'saucelabs-mocha': {
all: {
options: {
username: process.env.sauceuser,
key: saucekey,
testname: 'db.js',
tags: ['master'],
urls: ['http://127.0.0.1:9999/tests/index.html'],
public: !!process.env.TRAVIS_JOB_ID,
build: process.env.TRAVIS_JOB_ID,
browsers: [/* {
browserName: 'firefox',
platform: 'Windows 2012',
version: '17'
}, {
browserName: 'internet explorer',
platform: 'Windows 2012',
version: '10'
}, */
{
browserName: 'chrome',
platform: 'Windows 2008'
}]
},
onTestComplete: function (result, callback) {
console.dir(result);
}
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
ci: {
singleRun: true,
browsers: ['PhantomJS']
},
dev: {
singleRun: false,
browsers: ['PhantomJS']
},
'dev-single': {
singleRun: true,
browsers: ['PhantomJS']
}
},
eslint: {
target: ['src/db.js', 'src/test-worker.js']
},
babel: {
options: {
sourceMap: true
},
dist: {
files: {
'dist/db.js': 'src/db.js',
'tests/test-worker.js': 'src/test-worker.js'
}
}
},
browserify: {
dist: {
files: {
'dist/db.js': 'dist/db.js'
},
options: {
browserifyOptions: {
standalone: 'db'
}
}
}
},
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
dbjs: {
options: {
sourceMapIn: 'dist/db.js.map' // input sourcemap from a previous compilation
},
files: {
'dist/db.min.js': ['dist/db.js']
}
},
testworker: {
options: {
sourceMapIn: 'tests/test-worker.js.map' // input sourcemap from a previous compilation
},
files: {
'tests/test-worker.js': ['tests/test-worker.js']
}
}
}
});
// load all grunt tasks
require('matchdep').filterDev(['grunt-*', '!grunt-cli']).forEach(grunt.loadNpmTasks);
grunt.registerTask('forever', function () {
this.async();
});
var devJobs = ['eslint', 'babel', 'browserify', 'uglify', 'clean', 'jade'];
var karmaJobs = devJobs.slice();
if (process.env.TRAVIS_JOB_ID) {
karmaJobs.push('karma:ci');
} else {
karmaJobs.push('karma:dev-single');
}
grunt.registerTask('dev', devJobs);
grunt.registerTask('phantom', karmaJobs);
grunt.registerTask('test', function () {
var testJobs = karmaJobs.concat('connect');
if (saucekey && !process.env.TRAVIS_PULL_REQUEST) {
console.info('adding Saucelabs integration');
testJobs.push('saucelabs-mocha');
}
grunt.task.run(testJobs);
});
grunt.registerTask('default', 'test');
grunt.registerTask('test:local', function () {
grunt.task.run(devJobs);
grunt.task.run('connect:server:keepalive');
});
};