javascriptutilitiesbun

List files in directory with bun


Is it possible to list files in directory with bun?

Looked into the docs for the bun utilities but can't seem to find it. Perhaps I'm missing something.


Solution

  • Actually you can

    import { Glob } from "bun";
    
    const glob = new Glob("*");
    
    for (const file of glob.scanSync(".")) {
        console.log(file);
    }
    

    More in the documentation: https://bun.sh/docs/api/glob