UNPKG

1.97 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 var desc = Object.getOwnPropertyDescriptor(m, k);
5 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6 desc = { enumerable: true, get: function() { return m[k]; } };
7 }
8 Object.defineProperty(o, k2, desc);
9}) : (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 o[k2] = m[k];
12}));
13var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14 Object.defineProperty(o, "default", { enumerable: true, value: v });
15}) : function(o, v) {
16 o["default"] = v;
17});
18var __importStar = (this && this.__importStar) || function (mod) {
19 if (mod && mod.__esModule) return mod;
20 var result = {};
21 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22 __setModuleDefault(result, mod);
23 return result;
24};
25Object.defineProperty(exports, "__esModule", { value: true });
26exports.ensureUnixPath = void 0;
27const nodePath = __importStar(require("path"));
28const PATH_REGEXP = new RegExp('\\' + nodePath.win32.sep, 'g');
29const ensureUnixPathCache = new Map();
30const IS_WINDOWS = process.platform === 'win32';
31exports.ensureUnixPath = IS_WINDOWS
32 ? (path) => {
33 if (!path) {
34 return null;
35 }
36 const cachePath = ensureUnixPathCache.get(path);
37 if (cachePath) {
38 return cachePath;
39 }
40 // we use a regex instead of the character literal due to a bug in some versions of node.js
41 // the path separator needs to be preceded by an escape character
42 const normalizedPath = path.replace(PATH_REGEXP, nodePath.posix.sep);
43 ensureUnixPathCache.set(path, normalizedPath);
44 return normalizedPath;
45 }
46 : (path) => path;
47//# sourceMappingURL=path.js.map
\No newline at end of file