find files by extension, *.html under a folder in nodejs

后端 未结 14 686
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 23:57

I\'d like to find all *.html files in src folder and all its sub folders using nodejs. What is the best way to do it?

var folder = \'/project1/src\';
var ex         


        
14条回答
  •  有刺的猬
    2020-12-08 00:37

    You can use Filehound to do this.

    For example: find all .html files in /tmp:

    const Filehound = require('filehound');
    
    Filehound.create()
      .ext('html')
      .paths("/tmp")
      .find((err, htmlFiles) => {
        if (err) return console.error("handle err", err);
    
        console.log(htmlFiles);
    });
    

    For further information (and examples), check out the docs: https://github.com/nspragg/filehound

    Disclaimer: I'm the author.

提交回复
热议问题