Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@aretecode/flipfile / src / walk.ts
Size: Mime:
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
}