From 9b9c15ecc448d52b140d7a0d9dfc52756c55dd7a Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Thu, 18 May 2023 15:52:37 -0400 Subject: [PATCH] cut supports next-directory --- src/changelord.js | 12 +++++++----- src/command/cut.js | 6 +++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/changelord.js b/src/changelord.js index 0e27eb6..a11c64b 100755 --- a/src/changelord.js +++ b/src/changelord.js @@ -67,11 +67,13 @@ yargs(hideBin(process.argv)) throw "changelog is invalid"; }) ); - config.delete_next_dir_entries = () => - globby([ - config.changelog().project.next_directory + "/*.yml", - config.changelog().project.next_directory + "/*.yaml", - ]).then((files) => Promise.all(files.map(fs.remove))); + config.delete_next_dir_entries = async () => { + const changelog = await config.changelog(); + return globby([ + changelog.project.next_directory + "/*.yml", + changelog.project.next_directory + "/*.yaml", + ]).then((files) => Promise.all(files.map((f) => fs.remove(f)))); + }; config.save_changelog = async (changelog) => { if (!changelog) changelog = await config.changelog(); return fs.writeFile(config.source, yaml.stringify(changelog)); diff --git a/src/command/cut.js b/src/command/cut.js index cb72bfe..b325763 100644 --- a/src/command/cut.js +++ b/src/command/cut.js @@ -62,8 +62,12 @@ const handler = async (config) => { config.consola.info("running in dry mode, not saving\n", next); } else { await config.save_changelog(changelog); - if (changelog.project.next_directory) + if (changelog.project.next_directory) { + config.consola.info( + `removing files in ${changelog.project.next_directory}` + ); await config.delete_next_dir_entries(); + } } config.consola.success(`version ${next.version} is cut!`);