Skip to content

Commit 565a494

Browse files
committed
fix bundled env update availability check
1 parent 719bc2a commit 565a494

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/main/registry.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
getBundledPythonPath,
2020
getEnvironmentPath,
2121
getUserHomeDir,
22-
isPortInUse
22+
isPortInUse,
23+
versionWithoutSuffix
2324
} from './utils';
2425
import { SettingType, userSettings } from './config/settings';
2526
import { appData } from './config/appdata';
@@ -779,13 +780,10 @@ export class Registry implements IRegistry, IDisposable {
779780
return requirements.every((req, index, reqSelf) => {
780781
try {
781782
const version = environment.versions[req.name];
782-
// remove alpha / beta suffixes
783-
const versionWithoutSuffix = `${semver.major(version, {
784-
loose: true
785-
})}.${semver.minor(version, {
786-
loose: true
787-
})}.${semver.patch(version, { loose: true })}`;
788-
return semver.satisfies(versionWithoutSuffix, req.versionRange);
783+
return semver.satisfies(
784+
versionWithoutSuffix(version),
785+
req.versionRange
786+
);
789787
} catch (e) {
790788
return false;
791789
}

src/main/settingsdialog/settingsdialog.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as ejs from 'ejs';
55
import { app, BrowserWindow } from 'electron';
66
import * as path from 'path';
77
import * as fs from 'fs';
8-
const semver = require('semver');
98
import { ThemedWindow } from '../dialog/themedwindow';
109
import {
1110
CtrlWBehavior,
@@ -16,7 +15,7 @@ import {
1615
StartupMode,
1716
ThemeType
1817
} from '../config/settings';
19-
import { getBundledPythonPath } from '../utils';
18+
import { getBundledPythonPath, versionWithoutSuffix } from '../utils';
2019
import { IRegistry } from '../registry';
2120

2221
export class SettingsDialog {
@@ -69,8 +68,10 @@ export class SettingsDialog {
6968
const bundledEnv = registry.getEnvironmentByPath(bundledPythonPath);
7069
const jlabVersion = bundledEnv.versions['jupyterlab'];
7170
const appVersion = app.getVersion();
72-
const diff = semver.diff(appVersion, jlabVersion);
73-
if (diff !== 'prerelease') {
71+
72+
if (
73+
versionWithoutSuffix(jlabVersion) !== versionWithoutSuffix(appVersion)
74+
) {
7475
bundledEnvInstallationLatest = false;
7576
}
7677
} catch (error) {

src/main/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import * as path from 'path';
55
import * as fs from 'fs';
6+
import * as semver from 'semver';
67
import log from 'electron-log';
78
import { AddressInfo, createServer, Socket } from 'net';
89
import { app, nativeTheme } from 'electron';
@@ -230,3 +231,10 @@ export async function waitForFunction(
230231
}
231232
});
232233
}
234+
235+
// remove alpha / beta suffixes
236+
export function versionWithoutSuffix(version: string) {
237+
return `${semver.major(version, { loose: true })}.${semver.minor(version, {
238+
loose: true
239+
})}.${semver.patch(version, { loose: true })}`;
240+
}

0 commit comments

Comments
 (0)