forked from rwaldron/tessel-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
114 lines (95 loc) · 2.42 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
// System Objects
var cp = require("child_process");
var path = require("path");
// Third Party Dependencies
var tags = require("common-tags");
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
nodeunit: {
tests: [
"test/index.js"
]
},
jshint: {
options: {
latedef: false,
curly: true,
eqeqeq: true,
immed: true,
newcap: false,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
strict: false,
esnext: true,
globals: {
rewire: true,
exports: true,
document: true,
Promise: true,
WeakMap: true,
Map: true,
window: true,
IS_TEST_MODE: true
}
},
files: {
src: [
"Gruntfile.js",
"lib/**/*.js",
"test/**/*.js",
"eg/**/*.js"
]
}
},
jscs: {
all: [
"lib/**/*.js",
"test/**/*.js",
"Gruntfile.js",
],
options: {
config: ".jscsrc"
}
},
});
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-jscs");
grunt.loadNpmTasks("grunt-git-authors");
grunt.registerTask("default", ["jshint", "jscs", "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}
`;
}