Sha256: 41dee7f440b19fdcc7098a320b6aff9419c339ff7107b4d527aaa40e6813f89d

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env node

var fs = require('fs');
var execSync = require('child_process').execSync;
var conventionalChangelog = require('conventional-changelog');
var tempfile = require('tempfile');
var addStream = require('add-stream');
var URI = require('urijs');

var gemspec = JSON.parse(execSync('bundle exec exe/parse-gemspec-cli parse_gemspec-cli.gemspec'));

var options = { preset: 'angular' };
var homepageUrl = gemspec.homepage;
var url = new URI(homepageUrl);
var host = url.protocol() + '://' + url.authority();
var owner = url.pathname().split('/')[1];
var repository = url.pathname().split('/')[2];

var templateContext = {
  version: gemspec.version,
  host: host,
  owner: owner,
  repository: repository
};
var infile = 'changelog.md';
var outfile = 'changelog.md';
var changelogStream = conventionalChangelog(options, templateContext)
  .on('error', function(err) {
    console.error(err.toString());
    process.exit(1);
  });

var tmp = tempfile();
var readStream = fs.createReadStream(infile);

changelogStream
  .pipe(addStream(readStream))
  .pipe(fs.createWriteStream(tmp))
  .on('finish', function() {
    fs.createReadStream(tmp)
      .pipe(fs.createWriteStream(outfile));
  });

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parse_gemspec-cli-0.4.0 bin/conventional-changelog