const accessSync = require('fs-access').sync const chalk = require('chalk') const checkpoint = require('../checkpoint') const conventionalChangelog = require('conventional-changelog') const fs = require('fs') const runLifecycleScript = require('../run-lifecycle-script') const writeFile = require('../write-file') module.exports = function (args, newVersion) { if (args.skip.changelog) return Promise.resolve() return runLifecycleScript(args, 'prechangelog') .then(() => { return outputChangelog(args, newVersion) }) .then(() => { return runLifecycleScript(args, 'postchangelog') }) } function outputChangelog (args, newVersion) { return new Promise((resolve, reject) => { createIfMissing(args) var header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n' var oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8') // find the position of the last release and remove header: if (oldContent.indexOf('