Skip to content

Commit

Permalink
fix: allow providing no versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 3, 2023
1 parent 585594e commit ac84c39
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/commands/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ export default async function githubMain(args: Argv) {
const cwd = resolve(args.dir || "");
process.chdir(cwd);

const [action, ..._versions] = args._;
if (action !== "release" || _versions.length === 0) {
const [subCommand, ..._versions] = args._;
if (subCommand !== "release") {
consola.log(
"Usage: changelogen gh release <versions|all> [--dir] [--token]"
"Usage: changelogen gh release [all|versions...] [--dir] [--token]"
);
process.exit(1);
}

let versions = [..._versions].map((v) => v.replace(/^v/, ""));

const config = await loadChangelogConfig(cwd, {});

if (config.repo?.provider !== "github") {
Expand Down Expand Up @@ -58,6 +56,7 @@ export default async function githubMain(args: Argv) {

const changelogReleases = parseChangelogMarkdown(changelogMd).releases;

let versions = [..._versions].map((v) => v.replace(/^v/, ""));
if (versions[0] === "all") {
versions = changelogReleases.map((r) => r.version).sort();
} else if (versions.length === 0) {
Expand Down

0 comments on commit ac84c39

Please sign in to comment.