forked from tessel/tessel-av
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
141 lines (121 loc) · 3.25 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
140
141
// System Objects
var cp = require('child_process');
// Third Party Dependencies
var tags = require('common-tags');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
nodeunit: {
tests: [
'test/common/bootstrap.js',
'test/unit/*.js'
]
},
jshint: {
all: {
options: {
jshintrc: '.jshintrc'
},
src: [
'lib/**/*.js',
'Gruntfile.js',
]
},
tests: {
options: {
jshintrc: 'test/.jshintrc'
},
src: [
'test/**/*.js',
]
}
},
jscs: {
all: [
'lib/**/*.js',
'test/**/*.js',
'Gruntfile.js',
],
options: {
config: '.jscsrc'
}
},
jsbeautifier: {
all: [
'lib/**/*.js',
'test/**/*.js',
'Gruntfile.js',
],
options: {
js: {
braceStyle: 'collapse',
breakChainedMethods: false,
e4x: false,
evalCode: false,
indentChar: ' ',
indentLevel: 0,
indentSize: 2,
indentWithTabs: false,
jslintHappy: false,
keepArrayIndentation: false,
keepFunctionIndentation: false,
maxPreserveNewlines: 10,
preserveNewlines: true,
spaceBeforeConditional: true,
spaceInParen: false,
unescapeStrings: false,
wrapLineLength: 0
}
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-jsbeautifier');
// 'npm test' runs these tasks
grunt.registerTask('test', ['jshint', 'jscs', 'jsbeautifier', 'nodeunit']);
// Default task.
grunt.registerTask('default', ['test']);
// Support running a single test suite
grunt.registerTask('nodeunit:only', 'Run a single test specified by a target; usage: "grunt nodeunit:only:<module-name>[.js]"', function(file) {
if (file) {
grunt.config('nodeunit.tests', [
'test/common/bootstrap.js',
'test/unit/' + file + '.js'
]);
}
grunt.task.run('nodeunit');
});
grunt.registerTask('changelog', '`changelog:0.0.0--0.0.2` or `changelog`', (range) => {
var done = grunt.task.current.async();
if (!range) {
// grunt changelog
range = cp.execSync('git tag --sort version:refname').toString().split('\n');
} else {
// grunt changelog:previous--present
range = range.split('--');
}
range = range.filter(Boolean).reverse();
cp.exec(`git log --format='|%h|%s|' ${range[1]}..${range[0]}`, (error, result) => {
if (error) {
console.log(error.message);
return;
}
var rows = result.split('\n').filter(commit => {
return !commit.includes('|Merge ') && !commit.includes(range[0]);
}).join('\n');
// Extra whitespace above and below makes it easier to quickly copy/paste from terminal
grunt.log.writeln(`\n\n${changelog(rows)}\n\n`);
done();
});
});
};
function changelog(rows) {
return tags.stripIndent `
| Commit | Message/Description |
| ------ | ------------------- |
${rows}
`;
}