Skip to content

Commit 6cba41d

Browse files
committed
reorder last version check to ensure it always updates the server version.
1 parent 8c12cf4 commit 6cba41d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/cli/src/utils/versionCheck.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,33 @@ export async function checkForUpdates(): Promise<string | null> {
6060
try {
6161
const { name: packageName, version: currentVersion } = getPackageInfo();
6262

63+
console.log('packageName', packageName);
64+
console.log('currentVersion', currentVersion);
6365
const settingDir = getSettingsDir();
6466
const versionFilePath = path.join(settingDir, 'lastVersionCheck');
67+
68+
fetchLatestVersion(packageName)
69+
.then(async (latestVersion) => {
70+
console.log('latestVersion', latestVersion);
71+
return fsPromises.writeFile(versionFilePath, latestVersion, 'utf8');
72+
})
73+
.catch((error) => {
74+
logger.warn('Error fetching latest version:', errorToString(error));
75+
});
76+
6577
if (fs.existsSync(versionFilePath)) {
6678
const lastVersionCheck = await fsPromises.readFile(
6779
versionFilePath,
6880
'utf8',
6981
);
82+
console.log('lastVersionCheck', lastVersionCheck);
7083
return generateUpgradeMessage(
7184
currentVersion,
7285
lastVersionCheck,
7386
packageName,
7487
);
7588
}
7689

77-
fetchLatestVersion(packageName)
78-
.then(async (latestVersion) => {
79-
return fsPromises.writeFile(versionFilePath, latestVersion, 'utf8');
80-
})
81-
.catch((error) => {
82-
logger.warn('Error fetching latest version:', errorToString(error));
83-
});
84-
8590
return null;
8691
} catch (error) {
8792
// Log error but don't throw to handle gracefully

0 commit comments

Comments
 (0)