<commit_before>#!/usr/bin/env node

'use strict';

require('shelljs/global');
var execSync = require('child_process').execSync;

function isDirectoryClean() {
  var fatalState = config.fatal;
  config.fatal = false;
  var isUnstagedChanges = exec('git diff --exit-code', {silent:true}).code;
  var isStagedChanged =
    exec('git diff --cached --exit-code', {silent:true}).code;
  config.fatal = fatalState;

  return !(isUnstagedChanges || isStagedChanged);
}

function prerelease() {
  if (!isDirectoryClean()) {
    echo('RELEASE ERROR: Working directory must be clean to push release!');
    exit(1);
  }
}

function bump(version) {
  execSync('npm --no-git-tag-version version ' + version);
}

function changelog(releaseVersion, fileName) {
  var changelogFileName = fileName || 'CHANGELOG.md';
  execSync('touch ' + changelogFileName);
  execSync('node ./node_modules/.bin/changelog ' + releaseVersion + ' CHANGELOG.tmp');
  cat('CHANGELOG.tmp', changelogFileName).to('CHANGELOG.md.tmp');
  rm('CHANGELOG.tmp');
  rm(changelogFileName);
  mv('CHANGELOG.md.tmp', changelogFileName);
}

function commit(releaseVersion) {
  execSync('git add -A');
  execSync('git commit -m "chore(release): ' + releaseVersion + '"');
  execSync('git tag -f ' + releaseVersion);
  execSync('git push origin HEAD --tags');
}

function release(version, fileName) {
  prerelease();
  bump(version);
  var releaseVersion = 'v' + require(process.cwd() + '/package.json').version;
  changelog(releaseVersion, fileName);
  commit(releaseVersion);
}

release(process.argv[2], process.argv[3]);<commit_msg>fix(release.js): change relative changelog path<commit_after>#!/usr/bin/env node

'use strict';

require('shelljs/global');
var execSync = require('child_process').execSync;

function isDirectoryClean() {
  var fatalState = config.fatal;
  config.fatal = false;
  var isUnstagedChanges = exec('git diff --exit-code', {silent:true}).code;
  var isStagedChanged =
    exec('git diff --cached --exit-code', {silent:true}).code;
  config.fatal = fatalState;

  return !(isUnstagedChanges || isStagedChanged);
}

function prerelease() {
  if (!isDirectoryClean()) {
    echo('RELEASE ERROR: Working directory must be clean to push release!');
    exit(1);
  }
}

function bump(version) {
  execSync('npm --no-git-tag-version version ' + version);
}

function changelog(releaseVersion, fileName) {
  var changelogFileName = fileName || 'CHANGELOG.md';
  execSync('touch ' + changelogFileName);
  execSync('$(npm bin)/changelog ' + releaseVersion + ' CHANGELOG.tmp');
  cat('CHANGELOG.tmp', changelogFileName).to('CHANGELOG.md.tmp');
  rm('CHANGELOG.tmp');
  rm(changelogFileName);
  mv('CHANGELOG.md.tmp', changelogFileName);
}

function commit(releaseVersion) {
  execSync('git add -A');
  execSync('git commit -m "chore(release): ' + releaseVersion + '"');
  execSync('git tag -f ' + releaseVersion);
  execSync('git push origin HEAD --tags');
}

function release(version, fileName) {
  prerelease();
  bump(version);
  var releaseVersion = 'v' + require(process.cwd() + '/package.json').version;
  changelog(releaseVersion, fileName);
  commit(releaseVersion);
}

release(process.argv[2], process.argv[3]);
{'fraction_non_alphanumeric': 0.16164469554300062, 'fraction_numerical': 0.0018832391713747645, 'mean_word_length': 4.968164794007491, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1301281', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1051, 'n_words': 217}