Ai
1 Star 9 Fork 2

思伟/vuepress-plugin-helper-live2d

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
listFiles.js 836 Bytes
一键复制 编辑 原始数据 按行查看 历史
/**
* @description List files of provided path
*/
const fs = require('fs');
const path = require('path');
/**
* Lists files in the supplied directory path
* @param {String} dirPath The path to the dir
* @return {Array} An array that contains all the file paths
*/
module.exports = function listFiles(dirPath) {
try {
// 指定目录下所有文件名称
const lsDir = fs.readdirSync(dirPath);
const filesArr = [];
for (const fileName of lsDir) {
const pathName = path.join(dirPath, fileName);
if (fs.statSync(pathName).isDirectory()) {
// 三点运算符
filesArr.push(...listFiles(pathName));
} else {
filesArr.push(pathName);
}
}
return filesArr;
} catch (e) {
console.warn("Not Found dirPath Files:" + dirPath);
return null;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/zhousiwei/vuepress-plugin-helper-live2d.git
git@gitee.com:zhousiwei/vuepress-plugin-helper-live2d.git
zhousiwei
vuepress-plugin-helper-live2d
vuepress-plugin-helper-live2d
master

搜索帮助