sortier
Version:
An opinionated code sorter
15 lines (14 loc) • 527 B
JavaScript
import fs from "fs";
import { globbySync } from "globby";
export function getFiles(context) {
const { filepatterns } = context;
// Files that match the actual paths
const fullPathFiles = filepatterns.filter((filepattern) => fs.existsSync(filepattern));
const globMatchFiles = globbySync(context.filepatterns, {
dot: true,
});
const set = new Set();
fullPathFiles.forEach((value) => set.add(value));
globMatchFiles.forEach((value) => set.add(value));
return Array.from(set).sort();
}