forked from palantir/plottable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
140 lines (122 loc) · 3.51 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
/*eslint-env node */
module.exports = function(grunt) {
"use strict";
// run an arbitrary yarn command through grunt, e.g. grunt exec:yarn:build:test -> yarn run build:test
var execConfig = {
yarn: {
cmd: function () {
var yarnCommandName = Array.prototype.slice.call(arguments).join(":");
return "yarn run " + yarnCommandName;
}
}
};
var jscsConfig = {
files: ["Gruntfile.js", "quicktests/**/*.js"],
options: {
config: ".jscsrc"
}
};
var eslintConfig = {
target: ["Gruntfile.js", "quicktests/**/*.js"],
options: {
configFile: ".eslintrc"
}
};
var watchConfig = {
options: {
livereload: true,
spawn: false
},
quicktests: {
tasks: ["update-quicktests"],
files: ["quicktests/overlaying/tests/**/*.js"]
}
};
var blanketMochaConfig = {
all: ["test/coverage.html"],
options: {
// disable coverage for the time being since we intend to replace grunt-blanket-mocha
threshold: 0,
reporter: "spec"
}
};
var connectConfig = {
server: {
options: {
port: 9999,
hostname: "*",
base: "",
livereload: true
}
}
};
var saucelabsMochaConfig = {
all: {
options: {
urls: ["http://127.0.0.1:9999/test/tests.html"],
testname: "Plottable Sauce Unit Tests",
pollInterval: 5000,
statusCheckAttempts: 60,
maxRetries: 1,
browsers: [{
browserName: "firefox",
platform: "linux"
}, {
browserName: "chrome",
platform: "linux"
}, {
browserName: "internet explorer",
version: "11",
platform: "WIN7"
}, {
browserName: "safari",
platform: "OS X 10.11",
version: "10.0",
}]
}
}
};
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
jscs: jscsConfig,
eslint: eslintConfig,
exec: execConfig,
watch: watchConfig,
"blanket_mocha": blanketMochaConfig,
connect: connectConfig,
"saucelabs-mocha": saucelabsMochaConfig
});
// Loads the tasks specified in package.json
require("load-grunt-tasks")(grunt);
grunt.registerTask("dev-compile", [
"exec:yarn:build:tsc",
"exec:yarn:build:webpack",
"update-quicktests"
]);
grunt.registerTask("default", ["exec:yarn:start"]);
grunt.registerTask("test", ["dev-compile", "test-local"]);
grunt.registerTask("test-local", ["blanket_mocha"]);
grunt.registerTask("test-sauce", ["connect", "saucelabs-mocha"]);
grunt.registerTask("watch-quicktests", function() {
// Surpresses the "Running 'foo' task" messages
grunt.log.header = function() {};
grunt.task.run(["watch"]);
});
grunt.registerTask("lint", ["exec:yarn:lint", "jscs", "eslint"]);
// Disable saucelabs on dev environments by checking if SAUCE_USERNAME is an environment variable
if (process.env.SAUCE_USERNAME) {
grunt.registerTask("test-ci", ["dev-compile", "lint", "test-local", "test-sauce"]);
} else {
grunt.registerTask("test-ci", ["dev-compile", "lint", "test-local"]);
}
grunt.registerTask("update-quicktests", function() {
var qtJSON = [];
var rawtests = grunt.file.expand("quicktests/overlaying/tests/**/*.js");
rawtests.forEach(function(value) {
qtJSON.push({ path: value });
});
qtJSON = JSON.stringify(qtJSON);
qtJSON = qtJSON.split(",").join(",\n") + "\n";
grunt.file.write("quicktests/overlaying/list_of_quicktests.json", qtJSON);
});
};