Skip to content

Commit 0f51ef2

Browse files
authored
Update gren to latest (#7)
1 parent 7ea97be commit 0f51ef2

File tree

5 files changed

+61
-18
lines changed

5 files changed

+61
-18
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
22
npm-debug.log
33
tmp
4-
Gruntfile.js

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Gruntfile.js

Gruntfile.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* grunt-github-release-notes
3+
* https://github.com/alexcanessa/grunt-github-release-notes
4+
*
5+
* Copyright (c) 2015 Alex Canessa
6+
* Licensed under the MIT license.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = function(grunt) {
12+
// Project configuration.
13+
grunt.initConfig({
14+
gren: {
15+
release: {
16+
options: {
17+
username: 'github-tools',
18+
repo: 'github-release-notes'
19+
}
20+
}
21+
}
22+
});
23+
24+
// Actually load this plugin's task(s).
25+
grunt.loadTasks('tasks');
26+
27+
// plugin's task(s), then test the result.
28+
grunt.registerTask('release', ['gren']);
29+
30+
// By default, lint and run all tests.
31+
grunt.registerTask('default', ['gren']);
32+
33+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"gruntplugin"
3737
],
3838
"dependencies": {
39+
"chalk": "^1.1.3",
3940
"github-release-notes": "^0.6.3"
4041
}
4142
}

tasks/gren.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,38 @@
99
'use strict';
1010

1111
var GithubReleaseNotes = require('github-release-notes/src/gren.js');
12+
var utils = require('github-release-notes/src/utils');
13+
var chalk = require('chalk');
1214

1315
module.exports = function(grunt) {
16+
grunt.registerMultiTask('gren', 'Grunt plugin for the npm github-release-notes', function() {
17+
var options = this.options({});
18+
options.force = grunt.cli.options.force;
1419

15-
// Please see the Grunt documentation for more information regarding task
16-
// creation: http://gruntjs.com/creating-tasks
20+
var done = this.async();
21+
var gren = new GithubReleaseNotes(options);
1722

18-
grunt.registerMultiTask('gren', 'Grunt plugin for the npm github-release-notes', function() {
19-
var options = this.options({});
20-
var done = this.async();
21-
var gren = new GithubReleaseNotes(options);
23+
if (this.target !== 'release' && this.target !== 'changelog') {
24+
throw new Error('The target needs to be either release or changelog');
25+
}
2226

23-
if (this.target !== 'release' && this.target !== 'changelog') {
24-
throw new Error('The target needs to be either release or changelog');
25-
}
27+
var component = this;
2628

27-
var component = this;
29+
gren.init()
30+
.then(function() {
31+
return gren[component.target]();
32+
})
33+
.then(done)
34+
.catch(function(error) {
35+
utils.clearTasks(gren);
2836

29-
gren.init()
30-
.then(function (success) {
31-
if(success) {
32-
return gren[component.target]();
33-
}
34-
}).then(done);
35-
});
37+
console.error(error);
3638

39+
if (options.force) {
40+
console.log(chalk.bgYellow(chalk.black('\nSkipping because --force enabled')));
41+
42+
done();
43+
}
44+
});
45+
});
3746
};

0 commit comments

Comments
 (0)