blob: f5d657e5970b4654aa3519174c121f3b0ec91da6 [file] [log] [blame]
Yang Guo4fd355c2019-09-19 08:59:031module.exports = function (grunt) {
2 grunt.initConfig({
3 pkgFile: 'package.json',
4 files: {
5 adapter: [
6 'src/adapter.js'
7 ]
8 },
9 build: {
10 adapter: '<%= files.adapter %>'
11 },
12 eslint: {
13 target: [
14 '<%= files.adapter %>',
15 '*.js',
16 'lib/index.js',
17 'tasks/*.js',
18 'test/**/*.js'
19 ]
20 },
21 karma: {
22 adapter: {
23 configFile: 'karma.conf.js',
24 autoWatch: false,
25 singleRun: true,
26 reporters: ['dots']
27 }
28 },
29 'npm-publish': {
30 options: {
31 requires: ['build']
32 }
33 },
34 'npm-contributors': {
35 options: {
36 commitMessage: 'chore: update contributors'
37 }
38 },
39 conventionalChangelog: {
40 release: {
41 options: {
42 changelogOpts: {
43 preset: 'angular'
44 }
45 },
46 src: 'CHANGELOG.md'
47 }
48 },
49 bump: {
50 options: {
51 commitFiles: [
52 'package.json',
53 'CHANGELOG.md'
54 ],
55 commitMessage: 'chore: release v%VERSION%',
56 pushTo: 'upstream'
57 }
58 }
59 })
60
61 require('load-grunt-tasks')(grunt)
62 grunt.loadTasks('tasks')
63 grunt.registerTask('default', ['build', 'eslint', 'test'])
64 grunt.registerTask('test', ['karma'])
65
66 grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {
67 grunt.task.run([
68 'npm-contributors',
69 'bump:' + (type || 'patch') + ':bump-only',
70 'build',
71 'conventionalChangelog',
72 'bump-commit',
73 'npm-publish'
74 ])
75 })
76}