Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
computeParsedPatterns(result: Array, fromDir?: string): void {
const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from)
if (this.patterns.length === 0 && relativeFrom != null) {
// file mappings, from here is a file
result.push(new Minimatch(relativeFrom, minimatchOptions))
return
}
for (let pattern of this.patterns) {
if (relativeFrom != null) {
pattern = path.join(relativeFrom, pattern)
}
const parsedPattern = new Minimatch(pattern, minimatchOptions)
result.push(parsedPattern)
// do not add if contains dot (possibly file if has extension)
if (!pattern.includes(".") && !hasMagic(parsedPattern)) {
// https://github.com/electron-userland/electron-builder/issues/545
// add **/*
result.push(new Minimatch(`${pattern}/**/*`, minimatchOptions))
function getSourceFiles(sourceInfo) {
var excludeMatcher = sourceInfo.exclude && new Minimatch(sourceInfo.exclude);
var filesPromise = Q.nfcall(glob, sourceInfo.include);
return filesPromise.then(function(files) {
// Filter the files on whether they match the `exclude` property and whether they are files
var filteredFilePromises = files.map(function(file) {
if ( excludeMatcher && excludeMatcher.match(file) ) {
// Return a promise for `null` if the path is excluded
// Doing this first - it is synchronous - saves us even making the isFile call if not needed
return Q(null);
} else {
// Return a promise for the file if path is a file, otherwise return a promise for `null`
return qfs.isFile(file).then(function(isFile) { return isFile ? file : null; });
}
computeParsedPatterns(result: Array, fromDir?: string): void {
const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from)
if (this.patterns.length === 0 && relativeFrom != null) {
// file mappings, from here is a file
result.push(new Minimatch(relativeFrom, minimatchOptions))
return
}
for (let pattern of this.patterns) {
if (relativeFrom != null) {
pattern = path.join(relativeFrom, pattern)
}
const parsedPattern = new Minimatch(pattern, minimatchOptions)
result.push(parsedPattern)
// do not add if contains dot (possibly file if has extension)
if (!pattern.includes(".") && !hasMagic(parsedPattern)) {
// https://github.com/electron-userland/electron-builder/issues/545
// add **/*
result.push(new Minimatch(`${pattern}/**/*`, minimatchOptions))
}
}
}
setExcludeRegex()
{
// Exclude files regex
const regexs = []
const Minimatch = require('minimatch').Minimatch
for(const _excludeKey in this.config.exclude)
{
const _exclude = this.config.exclude[_excludeKey]
const minimatch = new Minimatch(_exclude, { dot: true })
let regex = '' + minimatch.makeRe()
regex = regex.replace('/^', '')
regex = regex.replace('$/', '')
regexs.push(regex)
}
this.excludeRegex = new RegExp(regexs.join('|'))
}
const ignoreMinmatches = settings.linting.ignorePatterns.map(pattern => new minimatch_1.Minimatch(pattern));
if (ignoreMinmatches.some(matcher => matcher.match(document.fileName) || matcher.match(relativeFileName))) {
function matchesGlobs(file: string, patterns: string[]): boolean {
for (let i = patterns.length - 1; i >= 0; --i) {
const glob = isNegated(patterns[i]);
const local = glob.pattern.startsWith('./');
if (local)
glob.pattern = glob.pattern.substr(2);
if (new Minimatch(glob.pattern, {matchBase: !local}).match(file))
return !glob.negated;
}
return false;
}
function normalizeSkip (val) {
if (val instanceof RegExp) {
return val.test.bind(val)
} else if (typeof val === 'function') {
return val
} else if (typeof val === 'string') {
var minimatch = new Minimatch(val)
return function (str) {
return str.includes(val) || minimatch.match(str)
}
} else {
throw new Error('Skip should be either a RegExp, function or string')
}
}
let getRegexString = (segment: string) => {
let mm = new minimatch.Minimatch(segment, { dot: true });
if (mm.empty)
return '^\\s*?$';
else{
return mm.makeRe().source;
}
}
return configFile.linterOptions.exclude.some(function (pattern) { return new minimatch_1.Minimatch(pattern).match(fullPath); });
}
.map(pattern => new Minimatch(path.normalize(pattern), { dot: true }));