Repository URL to install this package:
|
Version:
1.0.2 ▾
|
import { statSync, readdirSync } from 'fs'
export function walk(
dir: string,
options: { recursive: boolean } = { recursive: true }
) {
let results: string[] = []
readdirSync(dir).forEach(relativePath => {
const file = `${dir}/${relativePath}`
const stat = statSync(file)
if (options.recursive) {
if (stat && stat.isDirectory()) {
results = results.concat(walk(file))
} else {
results.push(file)
}
} else if (stat && stat.isDirectory()) {
results.push(file)
}
})
return results
}