forked from jakerella/jquery-mockjax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
158 lines (147 loc) · 3.6 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
153
154
155
156
157
158
module.exports = function(grunt) {
'use strict';
// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
banner: [
'/*! <%= pkg.title || pkg.name %>',
' * A Plugin providing simple and flexible mocking of ajax requests and responses',
' * ',
' * Version: <%= pkg.version %>',
' * Home: <%= pkg.homepage %>',
' * Copyright (c) <%= grunt.template.today("yyyy") %> Jordan Kasper, formerly appendTo;',
' * NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014',
' * ',
' * Dual licensed under the MIT or GPL licenses.',
' * http://opensource.org/licenses/MIT OR http://www.gnu.org/licenses/gpl-2.0.html',
' */\n'
].join('\n'),
// Task configuration
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['./src/jquery.mockjax.js'],
dest: './dist/jquery.mockjax.js'
}
},
uglify: {
options: {
preserveComments: 'some',
},
dist: {
src: './dist/jquery.mockjax.js',
dest: './dist/jquery.mockjax.min.js'
}
},
jshint: {
options: {
jshintrc: true
},
all: {
src: [
'./src/**/*.js',
'./Gruntfile.js',
'test/test.js',
'test/requirejs/*.js',
'test/nodejs/*.js'
]
}
},
qunit: { all: [] }, // NOTE: these tests are all run by the `test` task below to run against each jQuery version supported
test: {
all: {
jQueryVersions: [
'1.5.2',
'1.6.4',
'1.7.2',
'1.8.3',
'1.9.1',
'1.10.2',
'1.11.3',
'2.0.3',
'2.1.4'
]
},
requirejs: {
jQueryVersions: [
'1.7.2',
'1.8.3',
'1.9.1',
'1.10.2',
'1.11.3',
'2.0.3',
'2.1.4'
]
},
latestInBranch: {
jQueryVersions: [
'1.11.3',
'2.1.4'
]
},
oldestAndLatest: {
jQueryVersions: [
'1.5.2',
'1.11.3',
'2.1.4'
]
},
edge: {
jQueryVersions: ['git']
},
dist: {
file: 'dist-min.html',
jQueryVersions: [
'1.5.2',
'1.6.4',
'1.7.2',
'1.8.3',
'1.9.1',
'1.10.2',
'1.11.3',
'2.0.3',
'2.1.4'
]
}
},
mochaTest: {
nodejs: {
src: ['./test/nodejs/*.js']
}
},
watch: {
gruntfile: {
files: './Gruntfile.js'
},
source: {
files: './src/*.js',
tasks: ['jshint', 'test:latestInBranch']
}
}
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('dev', ['jshint', 'test:all', 'test:requirejs', 'mochaTest']);
grunt.registerTask('build', ['dev', 'concat', 'uglify', 'test:dist']);
grunt.registerTask('default', ['dev']);
grunt.registerTask('test', 'Executes QUnit tests with all supported jQuery versions', function() {
var i, l,
versionUrls = [],
source = arguments[0] || 'all',
versions = grunt.config.get('test' + ('.' + source) + '.jQueryVersions') || [],
file = grunt.config.get('test' + ('.' + source) + '.file') || 'index.html';
for (i=0, l=versions.length; i<l; ++i) {
grunt.log.writeln('Adding jQuery version to test: ' + versions[i]);
if (arguments[0] === 'requirejs') {
versionUrls.push('./test/requirejs/' + file + '?jquery=' + versions[i]);
} else {
versionUrls.push('./test/' + file + '?jquery=' + versions[i]);
}
}
grunt.config.set('qunit.options.urls', versionUrls);
grunt.task.run('qunit');
});
};