Skip to content

Commit

Permalink
bin: fix version parser for Jupyter 4.5.0
Browse files Browse the repository at this point in the history
Fixes #200
  • Loading branch information
n-riesco committed Jun 23, 2019
1 parent b49119c commit 7ee18d2
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions bin/rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,34 @@ function setJupyterInfoAsync(context, callback) {
}

context.args.frontend[0] = "jupyter";
context.frontend.version = stdout.toString().trim();
context.frontend.majorVersion = parseInt(
context.frontend.version.split(".")[0]
);
if (isNaN(context.frontend.majorVersion)) {
console.error(
"Error parsing Jupyter version:",
context.frontend.version
);
log("CONTEXT:", context);
process.exit(1);

var version;
var majorVersion;

// Parse version number before Jupyter 4.5.0
version = stdout.toString().trim();
majorVersion = parseInt(version.split(".")[0]);

if (isNaN(majorVersion)) {
// Parse version number after Jupyter 4.5.0
var match = stdout.match(/^jupyter core\s+: (\d+\.\d+\.\d+)/m);
if (match) {
version = match[1];
majorVersion = parseInt(version.split(".")[0]);
} else {
// Failed to parse the output of "jupyter --version"
console.warn(
"Warning: Unable to parse Jupyter version:",
stdout
);
version = "unknown";
majorVersion = Infinity;
}
}

context.frontend.version = version;
context.frontend.majorVersion = majorVersion;

if (callback) {
callback();
}
Expand Down

0 comments on commit 7ee18d2

Please sign in to comment.