Skip to content

Commit 2b46b35

Browse files
committed
handle semver exceptions
1 parent 54662e0 commit 2b46b35

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

src/main/main.ts

+34-30
Original file line numberDiff line numberDiff line change
@@ -302,42 +302,46 @@ async function needToUpdateBundledPythonEnvInstallation(): Promise<boolean> {
302302

303303
const appVersion = app.getVersion();
304304

305-
// if the version in appData is latest, then assume it is latest
306-
if (bundledEnvInAppData) {
307-
const jlabVersionInAppData = bundledEnvInAppData.versions['jupyterlab'];
305+
try {
306+
// if the version in appData is latest, then assume it is latest
307+
if (bundledEnvInAppData) {
308+
const jlabVersionInAppData = bundledEnvInAppData.versions['jupyterlab'];
308309

309-
if (
310-
semver.compare(
311-
versionWithoutSuffix(jlabVersionInAppData),
312-
versionWithoutSuffix(appVersion)
313-
) >= 0
314-
) {
315-
return false;
310+
if (
311+
semver.compare(
312+
versionWithoutSuffix(jlabVersionInAppData),
313+
versionWithoutSuffix(appVersion)
314+
) >= 0
315+
) {
316+
return false;
317+
}
316318
}
317-
}
318319

319-
// if not latest in appData check the active jupyterlab version
320-
// in case appData is outdated
321-
let outputVersion = '';
322-
if (
323-
await runCommandInEnvironment(
324-
getBundledPythonEnvPath(),
325-
"python -c 'import jupyterlab; print(jupyterlab.__version__)'",
326-
{
327-
stdout: msg => {
328-
outputVersion += msg;
329-
}
330-
}
331-
)
332-
) {
320+
// if not latest in appData check the active jupyterlab version
321+
// in case appData is outdated
322+
let outputVersion = '';
333323
if (
334-
semver.compare(
335-
versionWithoutSuffix(outputVersion.trim()),
336-
versionWithoutSuffix(appVersion)
337-
) === -1
324+
await runCommandInEnvironment(
325+
getBundledPythonEnvPath(),
326+
"python -c 'import jupyterlab; print(jupyterlab.__version__)'",
327+
{
328+
stdout: msg => {
329+
outputVersion += msg;
330+
}
331+
}
332+
)
338333
) {
339-
return true;
334+
if (
335+
semver.compare(
336+
versionWithoutSuffix(outputVersion.trim()),
337+
versionWithoutSuffix(appVersion)
338+
) === -1
339+
) {
340+
return true;
341+
}
340342
}
343+
} catch (error) {
344+
log.error('Failed to check for env update need.', error);
341345
}
342346

343347
return false;

0 commit comments

Comments
 (0)