Skip to content

Commit 5907d7f

Browse files
committed
Update Updater.ts
1 parent 1488d57 commit 5907d7f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/core/Updater.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ class Updater {
114114
for (const packageJsonPath of pathsToTry) {
115115
try {
116116
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
117-
if (packageJson.version) {
118-
this.versionCache = packageJson.version;
119-
this.logger.info(`Version read from package.json: v${this.versionCache}`);
120-
return this.versionCache;
117+
if (packageJson.version && typeof packageJson.version === 'string') {
118+
const version = packageJson.version as string;
119+
this.versionCache = version;
120+
this.logger.info(`Version read from package.json: v${version}`);
121+
return version;
121122
}
122123
} catch (error) {
123124
// Try next path
@@ -144,9 +145,10 @@ class Updater {
144145

145146
for (const versionFilePath of versionPathsToTry) {
146147
try {
147-
this.versionCache = readFileSync(versionFilePath, "utf-8").trim();
148-
this.logger.info(`Version read from version file: v${this.versionCache}`);
149-
return this.versionCache;
148+
const version = readFileSync(versionFilePath, "utf-8").trim();
149+
this.versionCache = version;
150+
this.logger.info(`Version read from version file: v${version}`);
151+
return version;
150152
} catch (error) {
151153
// Try next path
152154
continue;

0 commit comments

Comments
 (0)