-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
62 lines (54 loc) · 1.49 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
"use strict";
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-exec');
grunt.initConfig({
bump: {
options: {
files: ['package.json'],
commit: true,
commitMessage: 'Release version %VERSION%',
commitFiles: ['package.json'],
createTag: true,
tagName: '%VERSION%',
tagMessage: 'Version %VERSION%',
push: false,
prereleaseName: 'beta'
}
},
exec: {
ts: {
command: 'node_modules/typescript/bin/tsc'
}
}
});
function execExternal(cmd) {
return function() {
var done = this.async();
grunt.log.ok("Executing " + cmd);
require('child_process').exec(cmd, function(err, stdout, stderr) {
if (err) {
grunt.fatal('Error executing "' + cmd + '": ' + stderr);
}
console.log(stdout);
stderr && console.error(stderr);
done();
});
};
}
grunt.registerTask('release',
'Runs TypeScript compilation, increments the version and makes a tagged commit. Run as "grunt release:type", where "type" is "major", "minor", "patch", "prepatch", etc.)',
versionType => {
grunt.task.run([
'bump:' + versionType,
'exec:ts'
]);
}
);
grunt.registerTask('release:git-push', 'Pushes to git', execExternal('git push origin main --follow-tags'));
grunt.registerTask('release:npm-publish', 'Deploys to npm', execExternal('npm publish .'));
grunt.registerTask('release:deploy', 'Pushes a new release to github and deploys to npm', [
'release:git-push',
'release:npm-publish'
]);
};