From 0f9562ffec364e98996a4dfe06eab1d06d94b721 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Tue, 17 Mar 2015 10:24:16 +1100 Subject: [PATCH] chore(task): remove logics that is moved to conventional-changelog 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. --- README.md | 12 ++---------- tasks/changelog.js | 19 ++----------------- test/test.js | 1 - 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 250182a..3e0879c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tasks/changelog.js b/tasks/changelog.js index 1c5e265..11955bd 100644 --- a/tasks/changelog.js +++ b/tasks/changelog.js @@ -1,5 +1,4 @@ 'use strict'; - var changelog = require('conventional-changelog'); var exec = require('child_process').exec; @@ -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) { @@ -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:'); -} diff --git a/test/test.js b/test/test.js index 047fdb4..7768ef0 100644 --- a/test/test.js +++ b/test/test.js @@ -1,5 +1,4 @@ 'use strict'; - var fs = require('fs'); var test = require('ava');