-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: better descriptions * ci: remove console.log * feat: add option `exclude` * chore(refactor): improve option `exclude` * docs: improve documentation * chore: fix Dockerfile extensions
- Loading branch information
1 parent
5e1a405
commit 74becbc
Showing
36 changed files
with
201 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type Configs = { | ||
/** | ||
* Filter by path to match only the files that should be performed. | ||
* | ||
* @default /\.test\./i | ||
*/ | ||
filter?: RegExp; | ||
/** | ||
* Exclude by path to match only the files that should be performed. | ||
* | ||
* @default undefined | ||
*/ | ||
exclude?: RegExp | RegExp[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
#! /usr/bin/env node | ||
|
||
import { escapeRegExp } from '../helpers/get-files.js'; | ||
import { escapeRegExp } from '../modules/get-files.js'; | ||
import { getArg } from '../helpers/get-arg.js'; | ||
import { poku } from '../index.js'; | ||
|
||
const rawDirs = getArg('include'); | ||
const rawFilter = getArg('filter'); | ||
const rawExclude = getArg('exclude'); | ||
|
||
const dirs = rawDirs?.split(',') || []; | ||
|
||
poku(dirs, { | ||
filter: rawFilter ? new RegExp(escapeRegExp(rawFilter)) : undefined, | ||
exclude: rawExclude ? new RegExp(escapeRegExp(rawExclude)) : undefined, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import process from 'node:process'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import type { Configs } from '../@types/get-files.ts'; | ||
|
||
export const escapeRegExp = (string: string) => | ||
string.replace(/[.*+?^${}()[\]\\]/g, '\\$&'); | ||
|
||
const envFilter = process.env.FILTER?.trim() | ||
? new RegExp(escapeRegExp(process.env.FILTER), 'i') | ||
: null; | ||
|
||
export const getFiles = ( | ||
dirPath: string, | ||
files: string[] = [], | ||
configs?: Configs | ||
) => { | ||
const currentFiles = fs.readdirSync(dirPath); | ||
const defaultRegExp = /\.test\./i; | ||
const filter: RegExp = | ||
(envFilter | ||
? envFilter | ||
: configs?.filter instanceof RegExp | ||
? configs.filter | ||
: defaultRegExp) || defaultRegExp; | ||
|
||
const exclude: Configs['exclude'] = configs?.exclude | ||
? Array.isArray(configs.exclude) | ||
? configs.exclude | ||
: [configs.exclude] | ||
: undefined; | ||
|
||
for (const file of currentFiles) { | ||
const fullPath = path.join(dirPath, file); | ||
|
||
if (exclude && exclude.some((regex) => regex.test(fullPath))) continue; | ||
|
||
if (fs.statSync(fullPath).isDirectory()) getFiles(fullPath, files, configs); | ||
else if (filter.test(fullPath)) files.push(fullPath); | ||
} | ||
|
||
return files; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.