-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
21 lines (18 loc) · 805 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const path = require("path");
const {execSync} = require("child_process");
// XXX: this may look absurd, but it's actually necessary
// this index.js file gets used as a 'startupScript' for IJavascript
// when loaded by the IJavascript session server it has lost track of
// the module path and attempts to resolve this module using the
// process.cwd()... which isn't where these files are
let magicpatch;
try {
magicpatch = require("./lib/interpreter");
} catch (err) /* istanbul ignore next */ {
if (!(/Cannot find module '\.\/lib\/interpreter'/g.test(err.message))) {
throw err;
}
let magicpatchPath = path.dirname(execSync("magicpatch-location", {encoding: "utf8"}));
magicpatch = require(path.join(magicpatchPath, "./lib/interpreter"));
}
module.exports = magicpatch;