1
0
mirror of synced 2025-12-20 10:28:40 -05:00
Files
docs/script/helpers/walk-files.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

19 lines
579 B
JavaScript

#!/usr/bin/env node
import path from 'path'
import walk from 'walk-sync'
// [start-readme]
//
// A helper that returns an array of files for a given path and file extension.
//
// [end-readme]
export default function walkFiles(dir, ext, opts = {}) {
const dirPath = path.posix.join(process.cwd(), dir)
const walkSyncOpts = { includeBasePath: true, directories: false }
return walk(dirPath, walkSyncOpts)
.filter((file) => file.endsWith(ext) && !file.endsWith('README.md'))
.filter((file) => (opts.includeEarlyAccess ? file : !file.includes('/early-access/')))
}