Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lookupAlias(aliases, filename, dir) {
// First, try looking up the exact filename
let alias = aliases[filename];
if (alias == null) {
// Otherwise, try replacing glob keys
for (let key in aliases) {
let val = aliases[key];
if (typeof val === 'string' && isGlob(key)) {
let re = micromatch.makeRe(key, {capture: true});
if (re.test(filename)) {
alias = filename.replace(re, val);
break;
}
}
}
}
if (typeof alias === 'string') {
return this.resolveFilename(alias, dir);
}
return typeof alias === 'string' ? alias : null;
}
lookupAlias(aliases, filename, dir) {
// First, try looking up the exact filename
let alias = aliases[filename];
if (alias == null) {
// Otherwise, try replacing glob keys
for (let key in aliases) {
let val = aliases[key];
if (typeof val === 'string' && isGlob(key)) {
let re = micromatch.makeRe(key, {capture: true});
if (re.test(filename)) {
alias = filename.replace(re, val);
break;
}
}
}
}
if (typeof alias === 'string') {
return this.resolveFilename(alias, dir);
} else if (alias === false) {
return false;
}
return null;
}
// Only acknowledge languages with icons
if(!languageIcon)
return null;
// Lazily require the micromatch dependency due to its weight.
const Micromatch = require("micromatch");
pattern = path.dirname(filePath) + "/" + (/^\//.test(pattern) ? "" : "**") + "/" + pattern;
pattern = path.resolve(pattern);
// Normalise path separators on Windows
if("win32" === process.platform)
pattern = pattern.replace(/\\/g, "/");
pattern = Micromatch.makeRe(pattern, {
unixify: false,
nonegate: true,
dot: true,
});
return pattern
? [pattern, languageIcon]
: null;
})
.filter(a => a);
function mmToRe (mm) {
return micromatch.makeRe(mm)
}
return this.readIgnoreFiles().map(pattern => micromatch.makeRe(pattern))
}
export function makeRe(pattern: Pattern, options: MicromatchOptions): PatternRe {
return micromatch.makeRe(pattern, options);
}
function makeRe(pattern, options) {
return micromatch.makeRe(pattern, options);
}
exports.makeRe = makeRe;