-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
102 lines (93 loc) · 3.04 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
'use strict';
var fs = require('fs');
module.exports = function (grunt) {
// load npm tasks
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
jshintFiles: ['Gruntfile.js', 'app/**/*.js', '!app/**/_*.js', 'toplevel/**/*.js', '!toplevel/**/_*.js'],
pkg: grunt.file.readJSON('package.json'),
clean: {
reports: ['.reports'],
demo: ['demo']
},
jshint: {
options: {
jshintrc: true
},
test: '<%= jshintFiles %>',
jslint: {
options: {
reporter: 'jslint',
reporterOutput: '.reports/lint/jshint.xml'
},
files: {
src: '<%= jshintFiles %>'
}
},
checkstyle: {
options: {
reporter: 'checkstyle',
reporterOutput: '.reports/lint/jshint_checkstyle.xml'
},
files: {
src: '<%= jshintFiles %>'
}
}
},
bgShell: {
generator: {
cmd: 'cd demo && yo baboon'
},
link: {
cmd: 'npm link'
},
sudo_link: {
cmd: 'sudo npm link'
}
},
changelog: {
options: {
}
},
bump: {
options: {
files: ['package.json'],
updateConfigs: ['pkg'],
commitFiles: ['.'],
commitMessage: 'chore: release v%VERSION%',
push: false
}
}
});
// Register tasks.
grunt.registerTask('git:commitHook', 'Install git commit hook', function () {
grunt.file.copy('validate-commit-msg.js', '.git/hooks/commit-msg');
fs.chmodSync('.git/hooks/commit-msg', '0755');
grunt.log.ok('Registered git hook: commit-msg');
});
grunt.registerTask('mkdir:demo', 'Create test directory', function () {
grunt.file.mkdir(require('path').join(__dirname, 'demo'));
});
grunt.registerTask('link', 'Do npm link to test the generator', function () {
if (process.platform === 'win32') {
grunt.task.run(['bgShell:link']);
} else {
grunt.task.run(['bgShell:sudo_link']);
}
});
grunt.registerTask('test', 'Test the generator', function () {
grunt.task.run(['git:commitHook', 'jshint:test', 'clean:demo', 'mkdir:demo', 'link', 'bgShell:generator']);
});
grunt.registerTask('lint', ['jshint:test']);
grunt.registerTask('ci', ['clean', 'jshint:jslint', 'jshint:checkstyle']);
grunt.registerTask('release', 'Bump version, update changelog and tag version', function (version) {
grunt.task.run([
'bump:' + (version || 'patch') + ':bump-only',
'changelog',
'bump-commit'
]);
});
// Default task.
grunt.registerTask('default', 'lint');
};