putout
Version:
the pluggable code transformer
36 lines (26 loc) • 622 B
JavaScript
;
const picomatch = require('picomatch');
const {keys, assign} = Object;
module.exports = (name, match) => {
if (!match || !name)
return {};
const rules = {};
const globs = keys(match);
for (const glob of globs) {
const paths = [
glob,
`**/${glob}`,
`${glob}/**`,
`**/${glob}/**`,
];
const isMatch = picomatch(paths, {
dot: true,
});
if (isMatch(name)) {
assign(rules, match[glob]);
}
}
return {
rules,
};
};