|
9 | 9 | 'use strict'; |
10 | 10 |
|
11 | 11 | var GithubReleaseNotes = require('github-release-notes/src/gren.js'); |
| 12 | +var utils = require('github-release-notes/src/utils'); |
| 13 | +var chalk = require('chalk'); |
12 | 14 |
|
13 | 15 | 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; |
14 | 19 |
|
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); |
17 | 22 |
|
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 | + } |
22 | 26 |
|
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; |
26 | 28 |
|
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); |
28 | 36 |
|
29 | | - gren.init() |
30 | | - .then(function (success) { |
31 | | - if(success) { |
32 | | - return gren[component.target](); |
33 | | - } |
34 | | - }).then(done); |
35 | | - }); |
| 37 | + console.error(error); |
36 | 38 |
|
| 39 | + if (options.force) { |
| 40 | + console.log(chalk.bgYellow(chalk.black('\nSkipping because --force enabled'))); |
| 41 | + |
| 42 | + done(); |
| 43 | + } |
| 44 | + }); |
| 45 | + }); |
37 | 46 | }; |
0 commit comments