Skip to content

Commit

Permalink
Reusable regex
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed May 5, 2024
1 parent f2f64d0 commit f326277
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const __dirname = dirname(fileURLToPath(import.meta.url));

const directory = pathJoin(__dirname, '..', 'packages');

const jsonPathReg = /^([^.][^/]*\/)*[^.][^/]*\.json$/;

const andReg = /^(.*)-([\d.]+)-and-([\d.]+|higher)$/;

const misplacedChildren = new Map([
Expand Down Expand Up @@ -53,7 +55,7 @@ export async function readPackageFile(f) {

export async function read() {
const files = (await readdir(directory, {recursive: true})).filter(s =>
/^([^.][^/]*\/)*[^.][^/]*\.json$/.test(s)
jsonPathReg.test(s)
);
const pkgs = (await Promise.all(files.map(readPackageFile))).flat();
for (const [pkg] of walk(pkgs, p => p.packages)) {
Expand Down

0 comments on commit f326277

Please sign in to comment.