-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
gruntfile.js
58 lines (48 loc) · 1.64 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
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
var banner = [
'/**',
'* Ajax Autocomplete for jQuery, version ' + pkg.version,
'* (c) 2017 Tomas Kirda',
'*',
'* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.',
'* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete',
'*/'].join('\n') + '\n';
// Project configuration.
grunt.initConfig({
pkg: pkg,
uglify: {
options: {
banner: banner
},
build: {
src: 'src/jquery.autocomplete.js',
dest: 'dist/jquery.autocomplete.min.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
grunt.task.registerTask('build', 'Create release', function() {
var version = pkg.version,
src = grunt.file.read('src/jquery.autocomplete.js').replace('%version%', version),
filePath = 'dist/jquery.autocomplete.js';
// Update not minimized release version:
console.log('Updating: ' + filePath);
grunt.file.write(filePath, src);
// Minify latest version:
grunt.task.run('uglify');
// Update plugin version:
filePath = 'devbridge-autocomplete.jquery.json';
src = grunt.file.readJSON(filePath);
if (src.version !== version){
src.version = version;
console.log('Updating: ' + filePath);
grunt.file.write(filePath, JSON.stringify(src, null, 4));
} else {
console.log('No updates for: ' + filePath);
}
});
};