Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function listDirectoryFiles (
scanDirectory: string,
appRoot: string,
filterFn?: CommandsListFilterFn,
): string[] {
return fsReadAll(scanDirectory)
.filter((name) => !name.endsWith('.json')) // remove .json files
.map((name) => {
const relativePath = relative(appRoot, join(scanDirectory, name))
return slash(relativePath.startsWith('../') ? relativePath : `./${relativePath}`)
})
.filter((name) => {
if (typeof (filterFn) === 'function') {
return filterFn(name)
}
return Array.isArray(filterFn) ? !filterFn.includes(name) : true
})
}