node中读取文件夹,获取文件名称
提示
获取一个目录下的所有文件夹和文件
# glob模块
const glob = require('glob')
const path = require('path')
const filesPath = path.resolve(__dirname, './**/*.js')
glob(filesPath, {ignore: './node_modules/'}, (err, fileNames) => {
console.log('filesName', fileNames)
// fileNames是一个数组
// ['e:/fangdown/github/bpp-test/node_modules/concat-map/index.js']
})
# 总结
对于上传资源, 需要先获取文件夹内容,再逐个上传!可以用到这个模块
上次更新: 2021/12/19, 18:05:42