forked from yeoman/generator-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
89 lines (81 loc) · 2.18 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
'use strict';
var semver = require('semver');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: require('./package.json'),
jshint: {
all: {
options: {
jshintrc: './.jshintrc'
},
src: [
'**/index.js',
'*.js',
'!test/**/*.js',
'!node_modules/**/*.js'
]
}
},
changelog: {
options: {
dest: 'CHANGELOG.md',
versionFile: 'package.json'
}
},
release: {
options: {
bump: false, // we have our own bump
file: 'package.json',
commitMessage: 'chore(release): Release version <%= version %>',
tagName: 'v<%= version %>'
}
},
stage: {
options: {
files: ['CHANGELOG.md']
}
}
});
grunt.registerTask('default', ['jshint']);
grunt.registerTask('bump', 'Bump manifest version', function (type) {
var options = this.options({
file: grunt.config('pkgFile') || 'package.json'
});
function setup(file, type) {
var pkg = grunt.file.readJSON(file);
var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch');
return {
file: file,
pkg: pkg,
newVersion: newVersion
};
}
var config = setup(options.file, type);
grunt.file.write(
config.file,
JSON.stringify(config.pkg, null, ' ') + '\n'
);
grunt.config('pkg', config.pkg);
grunt.log.ok('Version bumped to ' + config.newVersion);
});
grunt.registerTask('stage', 'Git adds files', function () {
var files = this.options().files;
grunt.util.spawn({
cmd: process.platform === 'win32' ? 'git.cmd' : 'git',
args: ['add'].concat(files)
}, grunt.task.current.async());
});
// grunt-release will only commit the package.json file by default. Until
// https://github.com/geddski/grunt-release/pull/43/files lands, it should
// be patched to do the same so it commits the changelog as well.
grunt.registerTask('publish', function (type) {
grunt.task.run([
'default',
'bump' + (type ? ':' + type : ''),
'changelog',
'stage',
'release'
]);
});
};