-
Notifications
You must be signed in to change notification settings - Fork 663
Expand file tree
/
Copy pathmodules.js
More file actions
35 lines (33 loc) · 852 Bytes
/
Copy pathmodules.js
File metadata and controls
35 lines (33 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
if (process.env.BUNDLE || typeof document === "object") {
exports.cwd = "/";
exports.root = "/";
exports.pkg = null;
exports.require = null;
exports.resolve = null;
exports.tryResolve = null;
} else {
const resolveFrom = require("resolve-from");
let cwd = "/";
let root = cwd;
let pkg = null;
if (typeof process === "object" && typeof process.cwd === "function") {
try {
cwd = process.cwd();
pkg = require("lasso-package-root").getRootPackage(cwd);
if (pkg) root = pkg.__dirname;
} catch {
// ignore
}
}
exports.cwd = cwd;
exports.root = root;
exports.pkg = pkg;
exports.require = require;
exports.resolve = (id, from) => {
return resolveFrom(from || root, id);
};
exports.tryResolve = (id, from) => {
return resolveFrom.silent(from || root, id);
};
}