in tools/node-hermes/nodelib/path.js [151:276]
resolve: function resolve() {
var resolvedDevice = '';
var resolvedTail = '';
var resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path = void 0;
if (i >= 0) {
path = i < 0 || arguments.length <= i ? undefined : arguments[i];
validateString(path, 'path'); // Skip empty entries
if (path.length === 0) {
continue;
}
} else if (resolvedDevice.length === 0) {
path = process.cwd();
} else {
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive, or the process cwd if
// the drive cwd is not available. We're sure the device is not
// a UNC path at this points, because UNC paths are always absolute.
path = process.env["=".concat(resolvedDevice)] || process.cwd(); // Verify that a cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
if (path === undefined || StringPrototypeToLowerCase(StringPrototypeSlice(path, 0, 2)) !== StringPrototypeToLowerCase(resolvedDevice) && StringPrototypeCharCodeAt(path, 2) === CHAR_BACKWARD_SLASH) {
path = "".concat(resolvedDevice, "\\");
}
}
var len = path.length;
var rootEnd = 0;
var device = '';
var isAbsolute = false;
var code = StringPrototypeCharCodeAt(path, 0); // Try to match a root
if (len === 1) {
if (isPathSeparator(code)) {
// `path` contains just a path separator
rootEnd = 1;
isAbsolute = true;
}
} else if (isPathSeparator(code)) {
// Possible UNC root
// If we started with a separator, we know we at least have an
// absolute path of some kind (UNC or otherwise)
isAbsolute = true;
if (isPathSeparator(StringPrototypeCharCodeAt(path, 1))) {
// Matched double path separator at beginning
var j = 2;
var last = j; // Match 1 or more non-path separators
while (j < len && !isPathSeparator(StringPrototypeCharCodeAt(path, j))) {
j++;
}
if (j < len && j !== last) {
var firstPart = StringPrototypeSlice(path, last, j); // Matched!
last = j; // Match 1 or more path separators
while (j < len && isPathSeparator(StringPrototypeCharCodeAt(path, j))) {
j++;
}
if (j < len && j !== last) {
// Matched!
last = j; // Match 1 or more non-path separators
while (j < len && !isPathSeparator(StringPrototypeCharCodeAt(path, j))) {
j++;
}
if (j === len || j !== last) {
// We matched a UNC root
device = "\\\\".concat(firstPart, "\\").concat(StringPrototypeSlice(path, last, j));
rootEnd = j;
}
}
}
} else {
rootEnd = 1;
}
} else if (isWindowsDeviceRoot(code) && StringPrototypeCharCodeAt(path, 1) === CHAR_COLON) {
// Possible device root
device = StringPrototypeSlice(path, 0, 2);
rootEnd = 2;
if (len > 2 && isPathSeparator(StringPrototypeCharCodeAt(path, 2))) {
// Treat separator following drive name as an absolute path
// indicator
isAbsolute = true;
rootEnd = 3;
}
}
if (device.length > 0) {
if (resolvedDevice.length > 0) {
if (StringPrototypeToLowerCase(device) !== StringPrototypeToLowerCase(resolvedDevice)) // This path points to another device so it is not applicable
continue;
} else {
resolvedDevice = device;
}
}
if (resolvedAbsolute) {
if (resolvedDevice.length > 0) break;
} else {
resolvedTail = "".concat(StringPrototypeSlice(path, rootEnd), "\\").concat(resolvedTail);
resolvedAbsolute = isAbsolute;
if (isAbsolute && resolvedDevice.length > 0) {
break;
}
}
} // At this point the path should be resolved to a full absolute path,
// but handle relative paths to be safe (might happen when process.cwd()
// fails)
// Normalize the tail path
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
return resolvedAbsolute ? "".concat(resolvedDevice, "\\").concat(resolvedTail) : "".concat(resolvedDevice).concat(resolvedTail) || '.';
},