Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test: (what: string) => {
// this refactor is a tad overly verbose but makes for easy debugging
const pattern = getMatcherString(id, resolutionBase);
const fn = mm.matcher(pattern, { dot: true });
const result = fn(what);
return result;
}
};
exports.create = function (globs) {
if (!Array.isArray(globs)) globs = [globs]
var positives = []
var negatives = []
var accumulator = []
for (var i = 0; i < globs.length; i++) {
var glob = globs[i]
if (typeof glob === "string" && glob[0] === "!") {
// Create Minimatch instances for negative glob patterns
accumulator.push(micromatch.matcher(resolveGlob(glob)))
} else if (glob instanceof RegExp) {
accumulator.push(glob)
} else {
positives.push(glob)
negatives.push(accumulator.slice())
}
}
if (positives.length === 0) {
throw new Error("Missing positive glob")
}
var opts = {
nodir: true,
symlinks: {},
statCache: {},
matchSingle(fileName, pattern) {
if (!pattern) {
return false;
}
// Cache the micropatch "pattern parsing"
let isMatch = this.cache[pattern];
if (!isMatch) {
isMatch = micromatch.matcher(pattern);
this.cache[pattern] = isMatch;
}
return isMatch(fileName);
}
const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ).split ( sep ).join( '/' ) ) } );
include = ensureArray( include ).map( getMatcher );
const matchers = globs.map(each => micromatch.matcher(each, { dot: true }));
return (path: string) => {
module.exports = function (pattern, options) {
var opts = extend({ matchBase: true }, options);
var isMatch = mm.matcher(pattern, opts);
return function unignore(file) {
if (isMatch(file.path)) {
delete file.exclude;
file.include = true;
}
return file;
};
};
function glob(cwd, pattern, res) {
if (typeof str !== 'string' || typeof pattern !== 'string') {
throw new Error('verb/loader/glob requires a string.');
}
var files = fs.readdirSync(cwd);
var len = files.length;
res = res = {};
var isMatch = mm.matcher(pattern);
while (len--) {
var name = files[len];
var fp = path.join(cwd, name);
if (fs.statSync(fp).isDirectory()) {
glob(fp, pattern, res);
} else if (isMatch(fp)) {
var ext = path.extname(name);
var base = path.basename(name, ext);
res[base] = utils.toVinyl({
ext: ext,
dir: cwd,
path: fp,
basename: base,
content: fs.readFileSync(fp),
data: {}
const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ) ) } );
include = ensureArray( include ).map( getMatcher );
function matchFile(cwd, pattern, opts) {
var isMatch = mm.matcher(pattern, opts);
var files = tryReaddirSync(cwd);
var len = files.length;
var idx = -1;
while (++idx < len) {
var name = files[idx];
var fp = path.join(cwd, name);
if (isMatch(name) || isMatch(fp)) {
return fp;
}
}
return null;
}