node.js fs.readdir recursive directory search

前端 未结 30 1568
醉酒成梦
醉酒成梦 2020-11-22 15:55

Any ideas on an async directory search using fs.readdir? I realise that we could introduce recursion and call the read directory function with the next directory to read, bu

30条回答
  •  花落未央
    2020-11-22 16:15

    Another nice npm package is glob.

    npm install glob

    It is very powerful and should cover all your recursing needs.

    Edit:

    I actually wasn't perfectly happy with glob, so I created readdirp.

    I'm very confident that its API makes finding files and directories recursively and applying specific filters very easy.

    Read through its documentation to get a better idea of what it does and install via:

    npm install readdirp

提交回复
热议问题