Skip to content

Commit

Permalink
chore(task): remove logics that is moved to conventional-changelog
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This module no longer reads your package.json to find version and repository. This logic is moved to conventional-changelog. We want to make this one a pure grunt wrapper.
  • Loading branch information
stevemao committed Mar 16, 2015
1 parent a95e93b commit 0f9562f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ grunt.initConfig({

## Options

Supports all options from [conventional-changelog](http://github.com/ajoslin/conventional-changelog), with the following changes and additions:
Supports all options from [conventional-changelog](https://github.com/ajoslin/conventional-changelog#documentation), with the following additions:

### dest
Defaults to `CHANGELOG.md`. The destination to write the changelog, and to read the existing changelog from.

### version
Defaults to version in `grunt.config('pkg')` or `package.json`.

### repository
Defaults to `repository` or `repository.url`, found in `grunt.config('pkg')` or `package.json`.

By default, it expects a github repository. Check [conventional-changelog's README](http://github.com/ajoslin/conventional-changelog) for information on using non-github repositories.

### editor
If specified, it runs given command before finishing the task. This is useful if you want to manually polish the generated changelog.

For instance you can set it to `sublime -w`.
For instance you can set it to `subl -w`.

## License
BSD
19 changes: 2 additions & 17 deletions tasks/changelog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

var changelog = require('conventional-changelog');
var exec = require('child_process').exec;

Expand All @@ -8,22 +7,19 @@ module.exports = function(grunt) {
grunt.registerTask('changelog', DESC, function() {

var done = this.async();
var pkg = grunt.config('pkg') || grunt.file.readJSON('package.json') || {};

var options = this.options({
file: 'CHANGELOG.md',
prepend: true, // false to append
repository: getPackageRepository(pkg),
version: pkg.version,
editor: null, // 'sublime -w'
github: null //deprecated
github: null // deprecated
});

// grunt-conventional-changelog options -> conventional-changelog options
options.file = options.file || options.dest;
options.log = grunt.log.ok.bind(grunt);
options.warn = grunt.log.writeln.bind(grunt, '[warn]'.yellow);
options.repository = options.repository || options.github || '';
options.repository = options.repository || options.github;

// deprecated options.github
if (options.github) {
Expand Down Expand Up @@ -55,14 +51,3 @@ module.exports = function(grunt) {
});
});
};

function getPackageRepository(pkg) {
var repo = pkg.repository && pkg.repository.url || pkg.repository;

if (typeof repo !== 'string') {
return null;
}

//Change git://github.com/a/b.git to http://github.com/a/b
return repo.replace(/\.git$/, '').replace(/^git\:/, 'http:');
}
1 change: 0 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

var fs = require('fs');
var test = require('ava');

Expand Down

0 comments on commit 0f9562f

Please sign in to comment.