-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gruntfile.js
149 lines (139 loc) · 4.14 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
module.exports = function (grunt) {
require("time-grunt")(grunt);
require("load-grunt-tasks")(grunt);
var VERSION = require("./package.json").version,
BANNER = require("fs").readFileSync("src/notice.txt").toString();
grunt.initConfig({
"clean": {
"all": ["dist/**"]
},
"uglify": {
"outliner-js": {
"options": {
"banner": BANNER
},
"src": ["dist/debug/outliner.debug.js"],
"dest": "dist/outliner.min.js"
}
},
"_watch": {
autoBuild: {
files: ["src/**"],
tasks: ["default", "buster:local:test", "buster:jsdom:test"]
},
autoTest: {
files: ["test/**"],
tasks: ["buster:local:test", "buster:jsdom:test"]
}
},
buster: {
"local": {
"test": {
"reporter": "specification",
"config-group": "browser"
}
},
"jsdom": {
"test": {
"reporter": "specification",
"config-group": "jsdom"
}
}
},
open: {
"capture-browser": {
path: "http://127.0.0.1:1111/capture"
}
},
browserify: {
"outliner-js": {
"src": [
"index.js"
],
"dest": "dist/debug/outliner.debug.js",
"options": {
"banner": BANNER,
"browserifyOptions": {
"standalone": "HTML5Outline"
}
}
}
},
"saucelabs-custom": {
dist: {
options: {
testname: "HTML5 outliner",
build: process.env.TRAVIS_JOB_ID || "",
browsers: [
{browserName: "microsoftedge", version: "13"},
{browserName: "internet explorer", version: "11"},
{browserName: "internet explorer", version: "10"},
{browserName: "internet explorer", version: "9"},
{browserName: "firefox", platform: "Windows"},
{browserName: "firefox", platform: "OS X 10.11"},
{browserName: "firefox", platform: "Linux"},
{browserName: "chrome", platform: "Windows"},
{browserName: "chrome", platform: "OS X 10.11"},
{browserName: "chrome", platform: "Linux"},
{browserName: "safari", platform: "OS X 10.11"}
],
urls: [
"http://127.0.0.1:8000/?reporter=sauce"
]
}
}
},
"bump": {
"options": {
commitMessage: 'release %VERSION%',
commitFiles: [ "-a" ],
tagName: '%VERSION%',
tagMessage: 'version %VERSION%',
pushTo: 'origin'
}
}
});
grunt.renameTask("watch", "_watch");
grunt.registerTask("default", "Clean build and minify", ["clean:all", "browserify", "uglify"]);
grunt.registerTask("test", "Clean build, minify and run tests",
process.env.SAUCE_LABS === "true" ?
["default", "test-jsdom", "test-phantom", "test-sauce"] :
["default", "test-jsdom", process.env.TRAVIS === "true" ? "test-phantom" : "test-local"]
);
grunt.registerTask("test-sauce", ["buster-static", "saucelabs-custom"]);
grunt.registerTask("test-phantom", ["buster:local:server", "buster:local:phantomjs", "buster:local:test"]);
grunt.registerTask("test-local", ["buster:local:server", "buster:local:phantomjs", "open:capture-browser", "buster:local:test"]);
grunt.registerTask("test-jsdom", ["buster:jsdom:test"]);
grunt.registerTask("watch", ["buster:local:server", "buster:local:phantomjs", "open:capture-browser", "_watch"]);
grunt.registerTask("release", function () {
var bump = grunt.option("bump");
if (bump != "patch" && bump != "minor" && bump != "major") grunt.fail.fatal("Please pass --bump");
grunt.task.run(["checkbranch:master", "checkpending", "bump:" + bump]);
});
grunt.registerTask("buster-static", function () {
// @todo: move buster-static task to grunt-buster package
var done = this.async();
var resolveBin = require("resolve-bin"),
cp = require("child_process");
resolveBin("buster", {executable: "buster-static"}, function (e, busterStaticBinPath) {
if (e) {
grunt.fail.fatal(e);
return;
}
grunt.log.writeln("Spawning " + busterStaticBinPath + " --port 8000");
var busterStaticProcess = cp.spawn(process.execPath, [busterStaticBinPath, "--port", "8000"], {
env: process.env,
setsid: true
});
busterStaticProcess.stdout.once("data", function () {
done();
});
busterStaticProcess.stderr.on("data", function (data) {
grunt.fail.fatal(data);
});
process.on("exit", function () {
busterStaticProcess.kill();
})
})
});
};