-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.js
105 lines (92 loc) · 2.74 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
module.exports = function (grunt) {
var
build_dir = "build/",
pkg = require("./package.json"),
hljs = require("highlight.js");
function compressJsFile(file) {
var UglifyJS = require("uglify-js2");
var result = UglifyJS.minify(file);
return result.code;
}
function compressCssFile(file) {
var
UglifyCSS = require("uglifycss"),
jsesc = require("jsesc"),
result = UglifyCSS.processFiles([file]);
return jsesc(result);
}
function highlightHTML(html) {
return hljs.highlight("xml", html).value;
}
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.initConfig({
pkg: pkg,
copy: {
main: {
cwd: "public/",
src: "**",
dest: build_dir,
expand: true
},
},
'gh-pages': {
options: {
base: build_dir
},
src: ['**']
}
});
grunt.registerTask("default", ["build"]);
grunt.registerTask("build:compileStandAlone",
"Builds jasmine-all.js",
function() {
var output = grunt.template.process(
grunt.file.read("jasmine-all.jst"),
{ data: {
jasmineVersion: pkg.version,
jasmineCss: compressCssFile("lib/jasmine.css"),
jasmineHtmlReporter: grunt.file.read("lib/jasmine-html.js"),
jasmineCore: grunt.file.read("lib/jasmine.js"),
jasmineJquery: grunt.file.read("lib/jasmine-jquery.js")
} }
);
grunt.file.write(build_dir + "jasmine-all.js", output);
output = grunt.template.process(
grunt.file.read("index.html.jst"),
{ data: {
jasmineVersion: pkg.version,
scriptTag: highlightHTML('<script type="text/javascript" src="http://sukima.github.io/jasmine-all/jasmine-all-min.js"></script>'),
repo_url: "http://github.com/sukima/jasmine-all/",
examples: [
highlightHTML(grunt.file.read("examples/1.html")),
highlightHTML(grunt.file.read("examples/2.html")),
highlightHTML(grunt.file.read("examples/3.html"))
]
} }
);
grunt.file.write(build_dir + "index.html", output);
}
);
grunt.registerTask("build:compressStandAlone",
"Compresses js to jasmine-all-min.js",
function() {
grunt.file.write(build_dir + "jasmine-all-min.js", compressJsFile(build_dir + "jasmine-all.js"));
}
);
grunt.registerTask("build",
"Builds and minifies jasmine-all-min.js",
[
"build:compileStandAlone",
"build:compressStandAlone",
"copy"
]
);
grunt.registerTask("clean",
"Cleans the build directory",
function() {
grunt.file.delete(build_dir);
}
);
};
/* vim:set ts=2 sw=2 et fdm=marker: */