You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

elgg-conventional-changelog

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elgg-conventional-changelog - npm Package Compare versions

Comparing version

to
0.1.4

CHANGELOG.md

57

index.js

@@ -16,2 +16,3 @@

log: console.log.bind(console),
notes: '',
}, options || {});

@@ -23,7 +24,32 @@

git.getTags(function(err, tags) {
if (err || !tags) return done('Failed to read git tags.\n'+err);
writeChangelog(tags);
readNotes(options.notes, options.file).then(function (notes) {
options.notes = notes;
git.getTags(function(err, tags) {
if (err || !tags) {
return done('Failed to read git tags.\n'+err);
}
writeChangelog(tags);
});
});
// consider anything before first anchor as release notes
function readNotes(notes, file) {
return new Promise(function (resolve, reject) {
if (notes || !file || !fs.existsSync(file)) {
resolve(notes);
return;
}
fs.readFile(file, {encoding:'UTF-8'}, function(err, contents) {
if (err) {
return done('Failed to read ' + file + '.\n'+err);
}
var idx = contents.indexOf('<a name="');
resolve(idx ? contents.substr(0, idx) : '');
});
});
}
function writeChangelog(tags) {

@@ -36,7 +62,9 @@ options.exclude = options.exclude || tags;

git.getLog({
exclude: options.exclude,
exclude: options.exclude,
to: options.to,
}, function(err, gitLog) {
if (err) return done('Failed to read git log.\n'+err);
if (err) {
return done('Failed to read git log.\n'+err);
}
writeGitLog(gitLog);

@@ -49,10 +77,18 @@ });

options.log('Parsed %d contributors.', gitLog.contributors.length);
writer.writeLog(gitLog, options, function(err, changelog) {
if (err) return done('Failed to write changelog.\n'+err);
if (err) {
return done('Failed to write changelog.\n'+err);
}
if (options.file && fs.existsSync(options.file)) {
fs.readFile(options.file, {encoding:'UTF-8'}, function(err, contents) {
if (err) return done('Failed to read ' + options.file + '.\n'+err);
done(null, changelog + '\n' + String(contents));
if (err) {
return done('Failed to read ' + options.file + '.\n'+err);
}
// clear out release notes (already captured in log)
var idx = contents.indexOf('<a name="');
done(null, changelog + '\n' + String(contents.substring(idx)));
});

@@ -65,2 +101,1 @@ } else {

}

7

lib/writer.js

@@ -32,2 +32,3 @@ var es = require('event-stream');

types: {},
notes: '',
}, options || {});

@@ -76,3 +77,5 @@

writer.header(options.version);
stream.write(options.notes);
writer.contributors(gitLog.contributors);

@@ -107,3 +110,3 @@

};
this.contributors = function(contributors) {

@@ -110,0 +113,0 @@ stream.write('#### Contributors\n');

{
"name": "elgg-conventional-changelog",
"version": "0.1.3",
"version": "0.1.4",
"description": "Generate a markdown changelog from git commit metadata",

@@ -43,5 +43,6 @@ "main": "index.js",

"chai": "~1.7.2",
"sinon": "~1.7.3",
"shelljs": "~0.2.6"
"mocha": "^2.4.5",
"shelljs": "~0.2.6",
"sinon": "~1.7.3"
}
}