Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit c0545f5

Browse files
committed
fix: optional chain check when writing version back to package.json
1 parent 181196e commit c0545f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bin/set-config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ export async function setConfig(config) {
2525
const packagePath = fs.readFileSync(path.resolve(cwd, ROOT_PACKAGE_FILE))
2626
const packageFile = JSON.parse(packagePath)
2727

28-
if (configFile.metadata.version) {
28+
if (configFile.metadata?.version) {
2929
configFile.metadata.version = config.releaseVersion
3030
updateConfig = true
3131
}
3232

33-
if (packageFile.version === config.prevVersion) {
33+
if (
34+
typeof packageFile.version === "string" &&
35+
packageFile.version === config.prevVersion
36+
) {
3437
packageFile.version = config.releaseVersion
3538
updatePkg = true
3639
}

0 commit comments

Comments
 (0)