resolver/path.js
function resolve() {
		var resolvedDevice = '';
		var resolvedTail = '';
		var resolvedAbsolute = false;

		for (var i = arguments.length - 1; i >= -1; i--) {
			var path;
			if (i >= 0) {
				path = arguments[i];
			} else if (!resolvedDevice) {
				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. We're sure the device is not
				// a UNC path at this points, because UNC paths are always absolute.
				path = process.env['=' + resolvedDevice];
				// Verify that a drive-local cwd was found and that it actually points
				// to our drive. If not, default to the drive's root.
				if (path === undefined || path.slice(0, 3).toLowerCase() !== resolvedDevice.toLowerCase() + '\\') {
					path = resolvedDevice + '\\';
				}
			}

			assertPath(path);

			// Skip empty entries
			if (path.length === 0) {
				continue;
			}

			var len = path.length;
			var rootEnd = 0;
			var code = path.charCodeAt(0);
			var device = '';
			var isAbsolute = false;

			// Try to match a root
			if (len > 1) {
				if (code === 47 /*/*/ || code === 92 /*\*/) {
						// 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;

						code = path.charCodeAt(1);
						if (code === 47 /*/*/ || code === 92 /*\*/) {
								// Matched double path separator at beginning
								var j = 2;
								var last = j;
								// Match 1 or more non-path separators
								for (; j < len; ++j) {
									code = path.charCodeAt(j);
									if (code === 47 /*/*/ || code === 92 /*\*/) break;
								}
								if (j < len && j !== last) {
									var firstPart = path.slice(last, j);
									// Matched!
									last = j;
									// Match 1 or more path separators
									for (; j < len; ++j) {
										code = path.charCodeAt(j);
										if (code !== 47 /*/*/ && code !== 92 /*\*/) break;
									}
									if (j < len && j !== last) {
										// Matched!
										last = j;
										// Match 1 or more non-path separators
										for (; j < len; ++j) {
											code = path.charCodeAt(j);
											if (code === 47 /*/*/ || code === 92 /*\*/) break;
										}
										if (j === len) {
											// We matched a UNC root only

											device = '\\\\' + firstPart + '\\' + path.slice(last);
											rootEnd = j;
										} else if (j !== last) {
											// We matched a UNC root with leftovers

											device = '\\\\' + firstPart + '\\' + path.slice(last, j);
											rootEnd = j;
										}
									}
								}
							} else {
							rootEnd = 1;
						}
					} else if (code >= 65 /*A*/ && code <= 90 /*Z*/ || code >= 97 /*a*/ && code <= 122 /*z*/) {
						// Possible device root

						code = path.charCodeAt(1);
						if (path.charCodeAt(1) === 58 /*:*/) {
								device = path.slice(0, 2);
								rootEnd = 2;
								if (len > 2) {
									code = path.charCodeAt(2);
									if (code === 47 /*/*/ || code === 92 /*\*/) {
											// Treat separator following drive name as an absolute path
											// indicator
											isAbsolute = true;
											rootEnd = 3;
										}
								}
							}
					}
			} else if (code === 47 /*/*/ || code === 92 /*\*/) {
					// `path` contains just a path separator
					rootEnd = 1;
					isAbsolute = true;
				}

			if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
				// This path points to another device so it is not applicable
				continue;
			}

			if (resolvedDevice.length === 0 && device.length > 0) {
				resolvedDevice = device;
			}
			if (!resolvedAbsolute) {
				resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
				resolvedAbsolute = isAbsolute;
			}

			if (resolvedDevice.length > 0 && resolvedAbsolute) {
				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 = normalizeStringWin32(resolvedTail, !resolvedAbsolute);

		return resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail || '.';
	}
function resolve() {
		var resolvedDevice = '';
		var resolvedTail = '';
		var resolvedAbsolute = false;

		for (var i = arguments.length - 1; i >= -1; i--) {
			var path;
			if (i >= 0) {
				path = arguments[i];
			} else if (!resolvedDevice) {
				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. We're sure the device is not
				// a UNC path at this points, because UNC paths are always absolute.
				path = process.env['=' + resolvedDevice];
				// Verify that a drive-local cwd was found and that it actually points
				// to our drive. If not, default to the drive's root.
				if (path === undefined || path.slice(0, 3).toLowerCase() !== resolvedDevice.toLowerCase() + '\\') {
					path = resolvedDevice + '\\';
				}
			}

			assertPath(path);

			// Skip empty entries
			if (path.length === 0) {
				continue;
			}

			var len = path.length;
			var rootEnd = 0;
			var code = path.charCodeAt(0);
			var device = '';
			var isAbsolute = false;

			// Try to match a root
			if (len > 1) {
				if (code === 47 /*/*/ || code === 92 /*\*/) {
						// 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;

						code = path.charCodeAt(1);
						if (code === 47 /*/*/ || code === 92 /*\*/) {
								// Matched double path separator at beginning
								var j = 2;
								var last = j;
								// Match 1 or more non-path separators
								for (; j < len; ++j) {
									code = path.charCodeAt(j);
									if (code === 47 /*/*/ || code === 92 /*\*/) break;
								}
								if (j < len && j !== last) {
									var firstPart = path.slice(last, j);
									// Matched!
									last = j;
									// Match 1 or more path separators
									for (; j < len; ++j) {
										code = path.charCodeAt(j);
										if (code !== 47 /*/*/ && code !== 92 /*\*/) break;
									}
									if (j < len && j !== last) {
										// Matched!
										last = j;
										// Match 1 or more non-path separators
										for (; j < len; ++j) {
											code = path.charCodeAt(j);
											if (code === 47 /*/*/ || code === 92 /*\*/) break;
										}
										if (j === len) {
											// We matched a UNC root only

											device = '\\\\' + firstPart + '\\' + path.slice(last);
											rootEnd = j;
										} else if (j !== last) {
											// We matched a UNC root with leftovers

											device = '\\\\' + firstPart + '\\' + path.slice(last, j);
											rootEnd = j;
										}
									}
								}
							} else {
							rootEnd = 1;
						}
					} else if (code >= 65 /*A*/ && code <= 90 /*Z*/ || code >= 97 /*a*/ && code <= 122 /*z*/) {
						// Possible device root

						code = path.charCodeAt(1);
						if (path.charCodeAt(1) === 58 /*:*/) {
								device = path.slice(0, 2);
								rootEnd = 2;
								if (len > 2) {
									code = path.charCodeAt(2);
									if (code === 47 /*/*/ || code === 92 /*\*/) {
											// Treat separator following drive name as an absolute path
											// indicator
											isAbsolute = true;
											rootEnd = 3;
										}
								}
							}
					}
			} else if (code === 47 /*/*/ || code === 92 /*\*/) {
					// `path` contains just a path separator
					rootEnd = 1;
					isAbsolute = true;
				}

			if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
				// This path points to another device so it is not applicable
				continue;
			}

			if (resolvedDevice.length === 0 && device.length > 0) {
				resolvedDevice = device;
			}
			if (!resolvedAbsolute) {
				resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
				resolvedAbsolute = isAbsolute;
			}

			if (resolvedDevice.length > 0 && resolvedAbsolute) {
				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 = normalizeStringWin32(resolvedTail, !resolvedAbsolute);

		return resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail || '.';
	}
path.resolve([from ...], to)