From 56171f11fdcb66e2eb47944475a92616e792ab33 Mon Sep 17 00:00:00 2001 From: SegaraRai Date: Mon, 1 Jul 2024 00:43:24 +0900 Subject: [PATCH] ci: handle cases where changeset releases are empty --- scripts/nextVersion.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/nextVersion.ts b/scripts/nextVersion.ts index 18457f9..a33899c 100644 --- a/scripts/nextVersion.ts +++ b/scripts/nextVersion.ts @@ -1,18 +1,22 @@ import { spawnSync } from "node:child_process"; import { readFile } from "node:fs/promises"; +interface ChangesetStatus { + changesets: unknown[]; + releases: { name: string; newVersion: string }[]; +} + spawnSync("pnpm", ["changeset", "status", "--output", "changeset-status.json"]); const changesetStatus = JSON.parse( await readFile("changeset-status.json", "utf8") -) as { releases: { name: string; newVersion: string }[] }; +) as ChangesetStatus; const release = changesetStatus.releases.find( (release) => release.name === "vite-plugin-modular-tailwindcss" ); -if (!release) { - console.error("Release not found in changeset status"); - process.exit(1); +if (release) { + console.log(release.newVersion); +} else { + console.error("Not ready for release yet."); } - -console.log(release.newVersion);