forked from twbs/bootlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
152 lines (145 loc) · 3.85 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
150
151
152
/*!
* Bootlint's Gruntfile
* https://github.com/twbs/bootlint
* Copyright 2014-2015 Christopher Rebert
* Portions Copyright 2013-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootlint/blob/master/LICENSE)
*/
/*eslint-env node */
module.exports = function (grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
var fs = require('fs');
var npmShrinkwrap = require('npm-shrinkwrap');
// Load all grunt tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time at the end.
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: (
"/*!\n * Bootlint v<%= pkg.version %> (<%= pkg.homepage %>)\n" +
" * <%= pkg.description %>\n" +
" * Copyright (c) 2014-2015 Christopher Rebert\n" +
" * Licensed under the MIT License (https://github.com/twbs/bootlint/blob/master/LICENSE).\n" +
" */\n"
),
// Task configuration.
browserify: {
dist: {
src: 'src/bootlint.js',
dest: 'dist/browser/<%= pkg.name %>.js'
}
},
usebanner: {
options: {
banner: '<%= banner %>'
},
dist: {
src: ['dist/**/*.js']
}
},
nodeunit: {
files: ['test/**/*_test.js']
},
qunit: {
options: {
timeout: 10000
},
files: ['test/fixtures/**/*.html', '!test/fixtures/jquery/missing.html', '!test/fixtures/jquery/and_bs_js_both_missing.html', '!test/fixtures/charset/not-utf8.html']
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
web: {
src: ['app.js', 'bin/www']
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['src/**/*.js']
},
test: {
src: ['test/**/*.js', '!test/lib/**/*.js']
}
},
jscs: {
web: {
src: '<%= jshint.web.src %>'
},
gruntfile: {
src: '<%= jshint.gruntfile.src %>',
options: {
validateIndentation: 2
}
},
lib: {
src: '<%= jshint.lib.src %>'
},
test: {
src: '<%= jshint.test.src %>'
}
},
eslint: {
options: {
config: '.eslintrc'
},
web: {
src: '<%= jshint.web.src %>'
},
gruntfile: {
src: '<%= jshint.gruntfile.src %>'
},
lib: {
src: '<%= jshint.lib.src %>'
},
test: {
src: '<%= jshint.test.src %>'
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'nodeunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'nodeunit']
}
},
exec: {
npmUpdate: {
command: 'npm update'
}
}
});
// Tasks
grunt.registerTask('lint', ['jshint', 'jscs', 'eslint']);
grunt.registerTask('dist', ['browserify', 'usebanner']);
grunt.registerTask('test', ['lint', 'dist', 'nodeunit', 'qunit']);
grunt.registerTask('default', ['test']);
// Task for updating the cached npm packages used by the Travis build (which are controlled by test-infra/npm-shrinkwrap.json).
// This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
grunt.registerTask('update-shrinkwrap', ['exec:npmUpdate', '_update-shrinkwrap']);
grunt.registerTask('_update-shrinkwrap', function () {
var done = this.async();
npmShrinkwrap({dev: true, dirname: __dirname}, function (err) {
if (err) {
grunt.fail.warn(err);
}
var dest = 'test-infra/npm-shrinkwrap.json';
fs.renameSync('npm-shrinkwrap.json', dest);
grunt.log.writeln('File ' + dest.cyan + ' updated.');
done();
});
});
};