Skip to content

Commit

Permalink
simplify and revert name change
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Feb 4, 2024
1 parent 0e4fbea commit ae10ffe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async function fastifyStatic (fastify, opts) {
opts.root = normalizeRoot(opts.root)
checkRootPathForErrors(fastify, opts.root)

if (opts.setHeaders !== undefined && typeof opts.setHeaders !== 'function') {
const setHeaders = opts.setHeaders
if (setHeaders !== undefined && typeof setHeaders !== 'function') {
throw new TypeError('The `setHeaders` option must be a function')
}

Expand Down Expand Up @@ -156,9 +157,11 @@ async function fastifyStatic (fastify, opts) {
rootPath += '/'
}

for (let file of new Glob('**/**', {
const globIterable = new Glob('**/**', {
cwd: rootPath, absolute: false, follow: true, nodir: true, dot: opts.serveDotFiles
})) {
})

for (let file of globIterable) {
file = file.split(path.win32.sep).join(path.posix.sep)
const route = opts.hash ? getHashedAsset(file) : prefix + file

Expand Down
6 changes: 4 additions & 2 deletions lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ async function generateHashes (rootPaths, includeDotFiles = false, ignore = ['no
const queuePromises = []
const files = []

for await (const file of new Glob('**/**', {
const globAsyncIterable = new Glob('**/**', {
cwd: rootPath, absolute: true, follow: true, nodir: true, dot: includeDotFiles, ignore
})) {
})

for await (const file of globAsyncIterable) {
const normalizedFile = file.split(path.win32.sep).join(path.posix.sep)
files.push(normalizedFile)
queuePromises.push(queue.push(normalizedFile))
Expand Down

0 comments on commit ae10ffe

Please sign in to comment.