UNPKG

1.15 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.externalizePath = exports.normalizePath = void 0;
11const nodePath = require("path");
12const normalizationCache = new Map();
13function normalizePath(path) {
14 let result = normalizationCache.get(path);
15 if (result === undefined) {
16 result = nodePath.win32.normalize(path).replace(/\\/g, nodePath.posix.sep);
17 normalizationCache.set(path, result);
18 }
19 return result;
20}
21exports.normalizePath = normalizePath;
22const externalizationCache = new Map();
23function externalizeForWindows(path) {
24 let result = externalizationCache.get(path);
25 if (result === undefined) {
26 result = nodePath.win32.normalize(path);
27 externalizationCache.set(path, result);
28 }
29 return result;
30}
31exports.externalizePath = (() => {
32 if (process.platform !== 'win32') {
33 return (path) => path;
34 }
35 return externalizeForWindows;
36})();