forked from krux/postscribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrunt.js
117 lines (105 loc) · 2.87 KB
/
grunt.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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/* <%= pkg.description %>, v<%= pkg.version %> <%= pkg.homepage %>\n' +
'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, MIT license ' +
'<%= pkg.licenses[0].url %> */'
},
// run jshint on the files, with the options described below. Different globals defined based on file type
// 'node' for files that are run by node.js (module, process, etc.)
// 'browser' for files that are run by a browser (window, document, etc.)
lint: {
node: ['grunt.js', 'test/generate_expected.phantom.js'],
browser: ['postscribe.js']
},
jshint: {
// Apply to all js files
options: {
curly: true,
eqeqeq: true,
expr: true,
forin: true,
indent: 2,
latedef: false,
newcap: true,
noarg: true,
noempty: true,
white: false,
// debatable
sub: true,
undef: true,
// Really. Leave it
unused: true
},
globals: {},
// Just for the 'node' src files
node: {
globals: {
console: true,
process: true,
module: true,
require: true,
__dirname: true,
exports: true
}
},
// Just for the 'browser' src files
browser: {
// Let's be very strict here
options: {
loopfunc: true,
expr: true,
evil: true,
// Reluctantly added
eqnull: true
},
globals: {}
}
},
concat: {
dist: {
src: ['<banner:meta.banner>', 'htmlParser/htmlParser.js', 'postscribe.js'],
dest: 'dist/postscribe.js'
}
},
// Minify postscribe src to postscribe.min.js, prepending a banner
min: {
dist: {
src: ['<banner:meta.banner>', 'dist/postscribe.js'],
dest: 'dist/postscribe.min.js'
}
},
qunit: {
files: ['test/test.html']
},
watch: {
files: ['postscribe.js', 'test/*'],
tasks: 'lint qunit'
},
generate_expected: {
index: "<config:qunit.files>",
dest: "test/expected.js",
phantom: "test/generate_expected.phantom.js"
}
});
grunt.registerTask('generate_expected', "Generate Files", function() {
var done = this.async();
var data = grunt.config('generate_expected');
grunt.utils.spawn({cmd: 'phantomjs', args: [
data.phantom,
data.index,
data.dest
]}, function(error, result) {
if(error) {
console.error(result.stderr);
}
done(!error);
});
});
// Alias test
grunt.registerTask('test', 'generate_expected qunit');
// This is what gets run when you don't specify an argument for grunt.
grunt.registerTask('default', 'lint test');
};