-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
135 lines (124 loc) · 3.37 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
/*
* js-data-hal
* http://github.com/js-data/js-data-hal
*
* Copyright (c) 2014 Jason Dobry <http://www.js-data.io/js-data-hal>
* Licensed under the MIT license. <https://github.com/js-data/js-data-hal/blob/master/LICENSE>
*/
module.exports = function (grunt) {
'use strict';
require('jit-grunt')(grunt, {
coveralls: 'grunt-karma-coveralls'
});
require('time-grunt')(grunt);
var pkg = grunt.file.readJSON('package.json');
// Project configuration.
grunt.initConfig({
pkg: pkg,
clean: {
coverage: ['coverage/'],
dist: ['dist/']
},
jshint: {
all: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
jshintrc: '.jshintrc'
},
watch: {
dist: {
files: ['src/**/*.js'],
tasks: ['build']
}
},
uglify: {
main: {
options: {
banner: '/**\n' +
'* @author Jason Dobry <jason.dobry@gmail.com>\n' +
'* @file js-data-hal.min.js\n' +
'* @version <%= pkg.version %> - Homepage <http://wwwjs-data.io/js-data-hal>\n' +
'* @copyright (c) 2014 Jason Dobry\n' +
'* @license MIT <https://github.com/js-data/js-data-hal/blob/master/LICENSE>\n' +
'*\n' +
'* @overview Hal adapter for js-data.\n' +
'*/\n'
},
files: {
'dist/js-data-hal.min.js': ['dist/js-data-hal.js']
}
}
},
browserify: {
options: {
browserifyOptions: {
standalone: 'DSHalAdapter'
},
external: ['js-data']
},
dist: {
files: {
'dist/js-data-hal.js': ['src/index.js']
}
}
},
karma: {
options: {
configFile: './karma.conf.js'
},
dev: {
browsers: ['Chrome'],
autoWatch: true,
singleRun: false,
reporters: ['spec'],
preprocessors: {}
},
min: {
browsers: ['Firefox', 'PhantomJS'],
options: {
files: [
'bower_components/js-data/dist/js-data.min.js',
'dist/js-data-hal.min.js',
'karma.start.js',
'test/**/*.js'
]
}
},
ci: {
browsers: ['Firefox', 'PhantomJS']
}
},
coveralls: {
options: {
coverage_dir: 'coverage'
}
}
});
grunt.registerTask('version', function (filePath) {
var file = grunt.file.read(filePath);
file = file.replace(/<%= pkg\.version %>/gi, pkg.version);
grunt.file.write(filePath, file);
});
grunt.registerTask('banner', function () {
var file = grunt.file.read('dist/js-data-hal.js');
var banner = '/**\n' +
'* @author Jason Dobry <jason.dobry@gmail.com>\n' +
'* @file js-data-hal.js\n' +
'* @version ' + pkg.version + ' - Homepage <http://www.js-data.iojs-data-hal/>\n' +
'* @copyright (c) 2014 Jason Dobry \n' +
'* @license MIT <https://github.com/js-data/js-data-hal/blob/master/LICENSE>\n' +
'*\n' +
'* @overview Hal adapter for js-data.\n' +
'*/\n';
file = banner + file;
grunt.file.write('dist/js-data-hal.js', file);
});
grunt.registerTask('test', ['build', 'karma:ci', 'karma:min']);
grunt.registerTask('build', [
'clean',
'jshint',
'browserify',
'banner',
'uglify:main'
]);
grunt.registerTask('go', ['build', 'watch:dist']);
grunt.registerTask('default', ['build']);
};