-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
116 lines (102 loc) · 2.75 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
'use strict';
module.exports = function (grunt) {
var fs = require('fs');
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
});
grunt.initConfig({
shell: {
'bower-install': {
command: './node_modules/bower/bin/bower install'
}
},
jasmine: {
test: {
src: 'jquery.dim-background.js',
options: {
vendor: [
'bower_components/jquery/dist/jquery.js',
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
],
specs: 'specs/*.spec.js',
template : require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'reports/coverage.json',
report: {
type: 'lcov',
options: {
dir: 'reports/coverage'
}
}
}
}
}
},
coveralls: {
js: {
src: 'reports/coverage/lcov.info',
force: true
}
},
jshint: {
plugin: ['jquery.dim-background.js'],
grunt: {
options: {
node: true
},
files: {
src: ['Gruntfile.js']
}
}
},
uglify: {
js: {
files: {
'jquery.dim-background.min.js': ['jquery.dim-background.js']
}
}
},
watch: {
js: {
files: ['jquery.dim-background.js'],
tasks: ['uglify']
}
},
// github pages deployment:
copy: {
public: {
files: [
{ expand: true, src: ['jquery.dim-background.js', 'jquery.dim-background.min.js', 'demo/**'], dest: 'public/' }
]
}
},
'gh-pages': {
options: {
base: 'public'
},
src: ['**']
},
clean: ['.grunt/', 'public/']
});
grunt.registerTask('check-version', 'Checks that the version is the same in all manifest files.', function () {
var jsonFromFile = function (file) {
return JSON.parse( fs.readFileSync(file, 'utf-8') );
};
var assertVersion = function (file, version) {
var fileVersion = jsonFromFile(file).version;
if (fileVersion !== version) {
errors++;
grunt.log.error('Version of '+file+' should be "'+version+'", but is "'+fileVersion+'"');
}
};
var errors = 0;
var version = jsonFromFile('dim-background.jquery.json').version;
assertVersion('bower.json', version);
assertVersion('package.json', version);
return errors === 0;
});
grunt.registerTask('test', ['shell:bower-install', 'jasmine']);
grunt.registerTask('ci', ['test', 'coveralls']);
grunt.registerTask('deploy', ['uglify', 'copy:public', 'gh-pages']);
grunt.registerTask('default', ['jshint', 'uglify', 'test', 'check-version']);
};