Ignore specific file when walking
parent
07f0e2a084
commit
eade7e15b3
|
@ -1,9 +1,11 @@
|
|||
import { readdir } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
const walkDir = async function* (dir) {
|
||||
const walkDir = async function* (dir = '.', ignores = []) {
|
||||
const files = await readdir(dir, { withFileTypes: true })
|
||||
|
||||
for (const file of files) {
|
||||
if (ignores.includes(file.name)) continue
|
||||
|
||||
if (file.isDirectory()) {
|
||||
yield* walkDir(join(dir, file.name))
|
||||
} else {
|
||||
|
@ -34,9 +36,7 @@ const suite = async (folder = '.') => {
|
|||
|
||||
const total = totalreporter()
|
||||
|
||||
for await (const file of walkDir(folder)) {
|
||||
if (file.includes('node_modules')) continue
|
||||
if (file.startsWith('.git')) continue
|
||||
for await (const file of walkDir(folder, ['node_modules', '.git'])) {
|
||||
if (!file.endsWith('.test.js')) continue
|
||||
|
||||
const module = join(absolutePath, file)
|
||||
|
|
Loading…
Reference in New Issue