fix(jupyter): more robust Deno.jupyter namespace (#20710)

This commit is contained in:
Bartek Iwańczuk 2023-09-28 16:51:44 +02:00 committed by GitHub
parent 35fad4d2bc
commit 0bd53fd52d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 63 deletions

View file

@ -545,12 +545,19 @@ function bootstrapMainRuntime(runtimeOptions) {
// TODO(bartlomieju): this is not ideal, but because we use `ObjectAssign`
// above any properties that are defined elsewhere using `Object.defineProperty`
// are lost.
let jupyterNs = undefined;
ObjectDefineProperty(finalDenoNs, "jupyter", {
get() {
if (jupyterNs) {
return jupyterNs;
}
throw new Error(
"Deno.jupyter is only available in `deno jupyter` subcommand.",
);
},
set(val) {
jupyterNs = val;
},
});
}