UNPKG

npub

Version:

publishing tool for your node projects hosted on github

35 lines (34 loc) 1.13 kB
// Generated by CoffeeScript 2.0.0-beta7 void function () { var debug, fs, mkdirp, touch; fs = require('fs'); mkdirp = require('mkdirp'); touch = require('touch'); debug = require('debug')('changelog'); module.exports = function (dir, git) { return { build: function (callback) { debug('build'); return git.diffSinceLastTag(callback); }, write: function (changelog, filePath) { if (null == filePath) filePath = '/tmp/npub/changelog.md'; mkdirp.sync('/tmp/npub'); fs.writeFileSync(filePath, changelog, { flag: 'w' }); debug('wrote ' + filePath); return filePath; }, update: function (filePath) { var changelogPath, currentChangelog, newChangelog; changelogPath = '' + dir + '/CHANGELOG.md'; touch.sync(changelogPath); newChangelog = fs.readFileSync(filePath); currentChangelog = fs.readFileSync(changelogPath); newChangelog += currentChangelog; debug('prepend addition'); return this.write(newChangelog, changelogPath); } }; }; }.call(this);