-
Notifications
You must be signed in to change notification settings - Fork 14
/
Gruntfile.js
97 lines (80 loc) · 2.04 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
"use strict";
var request = require("request");
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
main: ["tmp"]
},
copy: {
main: {
src: ["_normalize.scss"],
dest: "tmp/normalize.scss"
}
},
sass: {
main: {
options: {
loadPath: process.cwd(),
sourcemap: "none",
style: "compressed"
},
src: ["tmp/normalize.scss"],
dest: "tmp/normalize.actual.css"
}
},
cssmin: {
main: {
options: {
keepSpecialComments: 0
},
expand: true,
filter: "isFile",
src: ["tmp/*.css"]
}
}
});
grunt.util.linefeed = "\n";
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-sass");
grunt.registerTask("get", function () {
var url = "http://necolas.github.com/normalize.css/latest/normalize.css";
var file = "tmp/normalize.expected.css";
var done = this.async();
request.get(url, function (err, res, body) {
if (!err && res.statusCode === 200) {
grunt.file.write(file, body);
grunt.log.writeln('File "' + file + '" created.');
}
done(err);
});
});
grunt.registerTask("compare", function () {
var actual = {
path: "tmp/normalize.actual.css",
content: ""
};
var expected = {
path: "tmp/normalize.expected.css",
content: ""
};
actual.content = grunt.file.read(actual.path);
expected.content = grunt.file.read(expected.path);
if (actual.content !== expected.content) {
grunt.fail.warn('File "' + actual.path + '" is not the same as file "' +
expected.path + '".');
}
grunt.log.writeln('File "' + actual.path + '" is the same as file "' +
expected.path + '".');
});
grunt.registerTask("test", [
"clean",
"copy",
"sass",
"get",
"cssmin",
"compare"
]);
};