Last active
November 18, 2015 08:08
-
-
Save frapontillo/736d80e184a7955245ea to your computer and use it in GitHub Desktop.
Gulp AngularJS Full Lib Changelog Generation Task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var conventionalChangelog = require('gulp-conventional-changelog'); | |
var transform = function(commit) { | |
var commitMap = { | |
'feat': 'Features', | |
'fix': 'Bug Fixes', | |
'docs': 'Documentation Changes', | |
'style': 'Style Changes', | |
'refactor': 'Code Refactoring', | |
'perf': 'Performance Improvements', | |
'revert': 'Reverts', | |
'test': 'Tests', | |
'chore': 'Chore Changes' | |
}; | |
if (!commitMap.hasOwnProperty(commit.type)) { | |
return; | |
} | |
commit.type = commitMap[commit.type]; | |
if (commit.scope === '*') { | |
commit.scope = ''; | |
} | |
if (typeof commit.hash === 'string') { | |
commit.hash = commit.hash.substring(0, 7); | |
} | |
if (typeof commit.subject === 'string') { | |
commit.subject = commit.subject.substring(0, 80); | |
} | |
commit.notes.map(function(note) { | |
if (note.title === 'BREAKING CHANGE') { | |
note.title = 'BREAKING CHANGES'; | |
} | |
return note; | |
}); | |
return commit; | |
}; | |
gulp.task('changelog', function() { | |
return gulp.src('CHANGELOG.md') | |
.pipe(conventionalChangelog({ | |
preset: 'angular' | |
}, {}, {}, {}, { | |
transform: transform | |
})) | |
.pipe(gulp.dest('./')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment