Sha256: f064bd9dea7129e9e8c32f64244f8a0d815fcacdfb175b6a509843f70a648924

Contents?: true

Size: 1.16 KB

Versions: 23

Compression:

Stored size: 1.16 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = pathToPattern;
function _path() {
  const data = require("path");
  _path = function () {
    return data;
  };
  return data;
}
const sep = `\\${_path().sep}`;
const endSep = `(?:${sep}|$)`;
const substitution = `[^${sep}]+`;
const starPat = `(?:${substitution}${sep})`;
const starPatLast = `(?:${substitution}${endSep})`;
const starStarPat = `${starPat}*?`;
const starStarPatLast = `${starPat}*?${starPatLast}?`;
function escapeRegExp(string) {
  return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
}
function pathToPattern(pattern, dirname) {
  const parts = _path().resolve(dirname, pattern).split(_path().sep);
  return new RegExp(["^", ...parts.map((part, i) => {
    const last = i === parts.length - 1;
    if (part === "**") return last ? starStarPatLast : starStarPat;
    if (part === "*") return last ? starPatLast : starPat;
    if (part.indexOf("*.") === 0) {
      return substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep);
    }
    return escapeRegExp(part) + (last ? endSep : sep);
  })].join(""));
}
0 && 0;

//# sourceMappingURL=pattern-to-regex.js.map

Version data entries

23 entries across 16 versions & 3 rubygems

Version Path
trusty-cms-6.3.1 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.51 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.51 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.50 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.50 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.49 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.48 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.48 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.47 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.47 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.46 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.46 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.45 node_modules/jscodeshift/node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.45 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.44 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.43 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.42 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.41 node_modules/@babel/core/lib/config/pattern-to-regex.js
immosquare-cleaner-0.1.40 node_modules/@babel/core/lib/config/pattern-to-regex.js