Skip to content

Commit

Permalink
fix: Improved error handling and input validation for project name in… (
Browse files Browse the repository at this point in the history
#362)

fix: Improved error handling and input validation for project name in script
  • Loading branch information
ursulabauer authored Jan 7, 2025
1 parent 54f175d commit 388f72b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions scripts/remove-stable-version-field.ts
Original file line number Diff line number Diff line change
@@ -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}`)

Check warning on line 21 in scripts/remove-stable-version-field.ts

View workflow job for this annotation

GitHub Actions / style

Unexpected console statement
} catch (error) {
console.error("Error reading or writing the file:", error)
process.exit(1)
}
}

main()
Expand Down

0 comments on commit 388f72b

Please sign in to comment.