source: trip-planner-front/node_modules/fast-glob/out/utils/path.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.removeLeadingDotSegment = exports.escape = exports.makeAbsolute = exports.unixify = void 0;
4const path = require("path");
5const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
6const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
7/**
8 * Designed to work only with simple paths: `dir\\file`.
9 */
10function unixify(filepath) {
11 return filepath.replace(/\\/g, '/');
12}
13exports.unixify = unixify;
14function makeAbsolute(cwd, filepath) {
15 return path.resolve(cwd, filepath);
16}
17exports.makeAbsolute = makeAbsolute;
18function escape(pattern) {
19 return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
20}
21exports.escape = escape;
22function removeLeadingDotSegment(entry) {
23 // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
24 // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
25 if (entry.charAt(0) === '.') {
26 const secondCharactery = entry.charAt(1);
27 if (secondCharactery === '/' || secondCharactery === '\\') {
28 return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
29 }
30 }
31 return entry;
32}
33exports.removeLeadingDotSegment = removeLeadingDotSegment;
Note: See TracBrowser for help on using the repository browser.