forked from winstonjs/winston-loggly
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
139 lines (134 loc) · 3.6 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
'use strict';
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
, meta: {
version: '<%= pkg.version %>'
, banner: '/*! <%= pkg.name %> - v<%= meta.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n'
}
, jshint: {
all: ['lib/**/*.js', 'Gruntfile.js']
, options: {
jshintrc: '.jshintrc'
}
}
, bump: {
patch: {
options: {
part: 'patch'
, tabSize: 2
}
, src: [
'package.json'
]
}
, minor: {
options: {
part: 'minor'
, tabSize: 2
}
, src: '<%= bump.patch.src %>'
}
, major: {
options: {
part: 'major'
, tabSize: 2
}
, src: '<%= bump.patch.src %>'
}
}
, simplemocha: {
options: {
timeout: 2000
, ignoreLeaks: true
, ui: 'bdd'
}
, all: {
src: ['test/**/*.js']
}
}
, shell: {
gitTag: {
command: 'git tag v<%= grunt.file.readJSON("package.json").version %>'
, options: {
stdout: true
, failOnError: true
}
}
, gitRequireCleanTree: {
command: 'function require_clean_work_tree(){\n' +
' # Update the index\n' +
' git update-index -q --ignore-submodules --refresh\n' +
' err=0\n' +
' # Disallow unstaged changes in the working tree\n' +
' if ! git diff-files --quiet --ignore-submodules --\n' +
' then\n' +
' echo >&2 "cannot $1: you have unstaged changes."\n' +
' git diff-files --name-status -r --ignore-submodules -- >&2\n' +
' err=1\n' +
' fi\n' +
' # Disallow uncommitted changes in the index\n' +
' if ! git diff-index --cached --quiet HEAD --ignore-submodules --\n' +
' then\n' +
' echo >&2 "cannot $1: your index contains uncommitted changes."\n' +
' git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2\n' +
' err=1\n' +
' fi\n' +
' if [ $err = 1 ]\n' +
' then\n' +
' echo >&2 "Please commit or stash them."\n' +
' exit 1\n' +
' fi\n' +
'} \n require_clean_work_tree'
, options: {
failOnError: true
}
}
, gitCommitPackage: {
command: 'git commit --amend -i package.json --reuse-message HEAD'
, options: {
stdout: true
, failOnError: true
}
}
, gitPush: {
command: 'git push origin master --tags'
, options: {
stdout: true
, failOnError: true
}
}
, npmPublish: {
command: 'npm publish'
, options: {
stdout: true
, failOnError: true
}
}
, npmTest: {
command: 'npm test'
, options: {
stdout: true
, failOnError: true
}
}
}
})
grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-simple-mocha')
grunt.loadNpmTasks('grunt-notify')
grunt.loadNpmTasks('grunt-shell')
grunt.loadNpmTasks('grunt-bumpx')
grunt.registerTask('test', ['simplemocha'])
grunt.registerTask('publish', [
'shell:gitRequireCleanTree'
, 'jshint'
, 'shell:npmTest'
, 'bump:' + (grunt.option('bump') || 'patch')
, 'shell:gitCommitPackage'
, 'shell:gitTag'
, 'shell:gitPush'
, 'shell:npmPublish'
])
}