gpt4 book ai didi

file - 具有文件查询功能的 NodeJS 库

转载 作者:太空宇宙 更新时间:2023-11-03 23:10:23 26 4
gpt4 key购买 nike

我正在寻找具有查询功能的库。假设我想获取项目中某个目录中的所有 JS 文件。我可以做类似的事情

filesystem.query({
paths:[{
path:"c:/path/to/dir",
recursive:true
}],
types:[".js"],
excludes:["test.js"]
},successFn,failFn);

有图书馆有这个功能吗?

最佳答案

使用fs.readdir

var fs = require('fs');
fs.readdir('.', function (error, files)
{
files.filter(function (fileName)
{
return /.*.js$/.test(fileName);
}).forEach(yourfunc);
});

使用glob

require("glob").glob("*.js", function (er, files) { ... });

关于file - 具有文件查询功能的 NodeJS 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15367567/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com