Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95399683
index.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 15, 09:50
Size
1 KB
Mime Type
text/x-java
Expires
Tue, Dec 17, 09:50 (2 d)
Engine
blob
Format
Raw Data
Handle
22978200
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
index.ts
View Options
import path from "path";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
export default function (
moduleName: string,
dirname: string,
absoluteRuntime: string | boolean,
) {
if (absoluteRuntime === false) return moduleName;
return resolveAbsoluteRuntime(
moduleName,
path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime),
);
}
function resolveAbsoluteRuntime(moduleName: string, dirname: string) {
try {
return path
.dirname(
require.resolve(`${moduleName}/package.json`, { paths: [dirname] }),
)
.replace(/\\/g, "/");
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
throw Object.assign(
new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`),
{
code: "BABEL_RUNTIME_NOT_FOUND",
runtime: moduleName,
dirname,
},
);
}
}
export function resolveFSPath(path: string) {
return require.resolve(path).replace(/\\/g, "/");
}
Event Timeline
Log In to Comment