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

后端 未结 14 846
隐瞒了意图╮
隐瞒了意图╮ 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:35

    Install

    you can install this package walk-sync by

    yarn add walk-sync
    

    Usage

    const walkSync = require("walk-sync");
    const paths = walkSync("./project1/src", {globs: ["**/*.html"]});
    console.log(paths);   //all html file path array
    

提交回复
热议问题