Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.removeLeadingDotSegment = exports.escape = exports.makeAbsolute = exports.unixify = void 0;
  4. const path = require("path");
  5. const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
  6. const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
  7. /**
  8. * Designed to work only with simple paths: `dir\\file`.
  9. */
  10. function unixify(filepath) {
  11. return filepath.replace(/\\/g, '/');
  12. }
  13. exports.unixify = unixify;
  14. function makeAbsolute(cwd, filepath) {
  15. return path.resolve(cwd, filepath);
  16. }
  17. exports.makeAbsolute = makeAbsolute;
  18. function escape(pattern) {
  19. return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  20. }
  21. exports.escape = escape;
  22. function 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. }
  33. exports.removeLeadingDotSegment = removeLeadingDotSegment;