forked from axios/axios
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
107 lines (93 loc) · 2.3 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) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/* <%= pkg.name %> v<%= pkg.version %> | (c) <%= grunt.template.today("yyyy") %> by Matt Zabriskie */\n'
},
clean: {
dist: 'dist/**'
},
ts: {
test: {
options: {
lib: [
'es5',
'es2015.promise',
'dom'
]
},
src: ['typings/index.d.ts', 'test/typescript/*.ts']
}
},
package2bower: {
all: {
fields: [
'name',
'description',
'version',
'homepage',
'license',
'keywords'
]
}
},
usebanner: {
all: {
options: {
banner: '<%= meta.banner %>',
linebreak: false
},
files: {
src: ['dist/*.js']
}
}
},
eslint: {
target: ['lib/**/*.js']
},
karma: {
options: {
configFile: 'karma.conf.js'
},
single: {
singleRun: true
},
continuous: {
singleRun: false
}
},
mochaTest: {
test: {
src: ['test/unit/**/*.js']
},
options: {
timeout: 30000,
},
},
watch: {
build: {
files: ['lib/**/*.js'],
tasks: ['build']
},
test: {
files: ['lib/**/*.js', 'test/**/*.js', '!test/typescript/axios.js', '!test/typescript/out.js'],
tasks: ['test']
}
},
webpack: require('./webpack.config.js')
});
grunt.registerMultiTask('package2bower', 'Sync package.json to bower.json', function () {
var npm = grunt.file.readJSON('package.json');
var bower = grunt.file.readJSON('bower.json');
var fields = this.data.fields || [];
for (var i=0, l=fields.length; i<l; i++) {
var field = fields[i];
bower[field] = npm[field];
}
grunt.file.write('bower.json', JSON.stringify(bower, null, 2));
});
grunt.registerTask('test', 'Run the jasmine and mocha tests', ['eslint', 'mochaTest', 'karma:single', 'ts']);
grunt.registerTask('build', 'Run webpack and bundle the source', ['clean', 'webpack']);
grunt.registerTask('version', 'Sync version info for a release', ['usebanner', 'package2bower']);
};