UNPKG

@solvprotocol/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

26 lines (22 loc) 624 B
import { Minimatch, IMinimatch } from 'minimatch'; export function matcher(patterns: string[]): (path: string) => boolean | undefined { const positivePatterns: IMinimatch[] = []; const negativePatterns: IMinimatch[] = []; for (const pat of patterns) { const m = new Minimatch(pat); if (m.negate) { negativePatterns.push(m); } else { positivePatterns.push(m); } } return path => { if (negativePatterns.some(m => !m.match(path))) { return false; } else if (positivePatterns.some(m => m.match(path))) { return true; } else { return undefined; } }; }