fix: use fs-jetpack in scripts/thumbs.js

This commit is contained in:
Bobby 2022-10-04 07:17:03 +07:00
parent ebd53996d7
commit 516457709f
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -1,3 +1,4 @@
const jetpack = require('fs-jetpack')
const path = require('path')
const paths = require('./../controllers/pathsController')
const utils = require('./../controllers/utilsController')
@ -9,12 +10,14 @@ const self = {
([2, 3].includes(self.mode) && utils.videoExts.includes(extname))
},
getFiles: async directory => {
const names = await paths.readdir(directory)
const names = await jetpack.listAsync(directory)
const files = []
for (const name of names) {
const lstat = await paths.lstat(path.join(directory, name))
if (lstat.isFile() && !name.startsWith('.')) {
files.push(name)
if (Array.isArray(names) && names.length) {
for (const name of names) {
const exists = await jetpack.existsAsync(path.join(directory, name))
if (exists === 'file' && !name.startsWith('.')) {
files.push(name)
}
}
}
return files