inital
This commit is contained in:
18
node_modules/node-retrieve-globals/util/getWorkingDirectory.js
generated
vendored
Normal file
18
node_modules/node-retrieve-globals/util/getWorkingDirectory.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
function addTrailingSlash(path) {
|
||||
if(path.endsWith("/")) {
|
||||
return path;
|
||||
}
|
||||
return path + "/";
|
||||
}
|
||||
|
||||
|
||||
function getWorkingDirectory() {
|
||||
// Trailing slash required
|
||||
// `import` and `require` should both be relative to working directory (not this file)
|
||||
return addTrailingSlash(pathToFileURL(path.resolve(".")).toString());
|
||||
}
|
||||
|
||||
export { getWorkingDirectory };
|
23
node_modules/node-retrieve-globals/util/vmModules.js
generated
vendored
Normal file
23
node_modules/node-retrieve-globals/util/vmModules.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import vm from "vm";
|
||||
|
||||
function isSupported() {
|
||||
// node --experimental-vm-modules …
|
||||
if(process.execArgv.find(entry => entry == "--experimental-vm-modules")) {
|
||||
return true;
|
||||
}
|
||||
// NODE_OPTIONS='--experimental-vm-modules' node …
|
||||
if((process.env?.NODE_OPTIONS || "").split(" ").find(entry => entry == "--experimental-vm-modules")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Feature test for a future when --experimental-vm-modules is not needed
|
||||
// and vm.Module is stable:
|
||||
try {
|
||||
new vm.SourceTextModule(`/* hi */`);
|
||||
return true;
|
||||
} catch(e) {}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export { isSupported };
|
Reference in New Issue
Block a user