cut supports next-directory

This commit is contained in:
Yanick Champoux 2023-05-18 15:52:37 -04:00
parent a841165c51
commit 9b9c15ecc4
2 changed files with 12 additions and 6 deletions

View File

@ -67,11 +67,13 @@ yargs(hideBin(process.argv))
throw "changelog is invalid"; throw "changelog is invalid";
}) })
); );
config.delete_next_dir_entries = () => config.delete_next_dir_entries = async () => {
globby([ const changelog = await config.changelog();
config.changelog().project.next_directory + "/*.yml", return globby([
config.changelog().project.next_directory + "/*.yaml", changelog.project.next_directory + "/*.yml",
]).then((files) => Promise.all(files.map(fs.remove))); changelog.project.next_directory + "/*.yaml",
]).then((files) => Promise.all(files.map((f) => fs.remove(f))));
};
config.save_changelog = async (changelog) => { config.save_changelog = async (changelog) => {
if (!changelog) changelog = await config.changelog(); if (!changelog) changelog = await config.changelog();
return fs.writeFile(config.source, yaml.stringify(changelog)); return fs.writeFile(config.source, yaml.stringify(changelog));

View File

@ -62,9 +62,13 @@ const handler = async (config) => {
config.consola.info("running in dry mode, not saving\n", next); config.consola.info("running in dry mode, not saving\n", next);
} else { } else {
await config.save_changelog(changelog); 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(); await config.delete_next_dir_entries();
} }
}
config.consola.success(`version ${next.version} is cut!`); config.consola.success(`version ${next.version} is cut!`);
}; };