-
Notifications
You must be signed in to change notification settings - Fork 131
/
Gruntfile.js
107 lines (102 loc) · 2.9 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
module.exports = function( grunt ) {
'use strict';
function packageVersion() {
return require('./package.json').version;
}
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// specifying JSHint options and globals
// https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
jshint: {
options: {
boss: true,
browser: true,
curly: true,
eqeqeq: true,
eqnull: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
globals: {
global: true,
jasmine: false,
module: false,
exports: true,
describe: false,
it: false,
expect: false,
beforeEach: false,
afterEach: false,
spyOn: false,
getJasmineRequireObj: false,
require: false
}
},
all: ['Gruntfile.js', 'src/**/*.js', 'lib/**/*.js', 'spec/**/*.js']
},
packageVersion: packageVersion(),
shell: {
ctags: {
command: 'ctags -R lib'
},
release: {
command: [
'git tag v<%= packageVersion %>',
'git push origin main --tags',
'npm publish'
].join('&&')
}
},
template: {
options: {
data: function() {
return {
packageVersion: packageVersion(),
files: grunt.file.expand([
'src/requireAjax.js',
'src/**/*.js',
'!src/boot.js'
])
};
}
},
lib: {
src: 'src/boot.js',
dest: '.tmp/mock-ajax.js'
}
},
includes: {
options: {
includeRegexp: /\/\/\s*include "(\S+)";/,
includePath: '.'
},
lib: {
src: '.tmp/mock-ajax.js',
dest: 'lib/mock-ajax.js'
}
}
});
grunt.registerTask('versionCheck', function() {
var pkgVersion = packageVersion(),
bower = require('./bower.json'),
bowerVersion = bower.version;
if (pkgVersion !== bowerVersion) {
grunt.fail.fatal("package.json and bower.json have different version numbers\n\tpackage.json:\t" + pkgVersion + "\n\tbower.json:\t" + bowerVersion);
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-template');
grunt.loadNpmTasks('grunt-includes');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['jshint']);
grunt.registerTask('build', ['template:lib', 'includes:lib']);
grunt.registerTask('ctags', 'Generate ctags', ['shell:ctags']);
grunt.registerTask('release', 'Release ' + packageVersion() + ' to npm', ['versionCheck', 'shell:release']);
};