diff --git a/scripts/remove-stable-version-field.ts b/scripts/remove-stable-version-field.ts index 861ede2db..bdb5225ff 100644 --- a/scripts/remove-stable-version-field.ts +++ b/scripts/remove-stable-version-field.ts @@ -1,17 +1,28 @@ import { readFileSync, writeFileSync } from "node:fs" async function main() { - const projectDirectory = `packages/${process.argv[2]}` + const projectName = process.argv[2] + if (!projectName) { + console.error("Please specify the project name as the second argument.") + process.exit(1) + } + const projectDirectory = `packages/${projectName}` const filePath = `${projectDirectory}/package.json` - const content = JSON.parse(readFileSync(filePath, "utf8")) + try { + const content = JSON.parse(readFileSync(filePath, "utf8")) - if (content.stableVersion) { - delete content.stableVersion - } + if (content.stableVersion) { + delete content.stableVersion + } - writeFileSync(filePath, JSON.stringify(content, null, 4), "utf8") + writeFileSync(filePath, JSON.stringify(content, null, 4), "utf8") + console.log(`Successfully updated ${filePath}`) + } catch (error) { + console.error("Error reading or writing the file:", error) + process.exit(1) + } } main()