From a841165c51390ef5ecf9b60ab3ed8c36d29cee85 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Thu, 18 May 2023 15:42:34 -0400 Subject: [PATCH] delete directory entries when cutting --- src/changelord.js | 5 +++++ src/command/cut.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/changelord.js b/src/changelord.js index 1dd55d4..0e27eb6 100755 --- a/src/changelord.js +++ b/src/changelord.js @@ -67,6 +67,11 @@ 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.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 a3669ed..cb72bfe 100644 --- a/src/command/cut.js +++ b/src/command/cut.js @@ -62,6 +62,8 @@ 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) + await config.delete_next_dir_entries(); } config.consola.success(`version ${next.version} is cut!`);