Skip to content

Commit

Permalink
fix: Use absolute path in #src/utils/fs.with*Dir() functions
Browse files Browse the repository at this point in the history
This will avoid problems when an absolute path is mandatory, for example
when using JavaScript’s built-in `import()` function.
  • Loading branch information
fabschurt committed May 6, 2024
1 parent 0a59f06 commit 7e91397
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/fs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'node:fs/promises'
import { join } from 'node:path'
import { join, resolve } from 'node:path'

const prefixWithDir = (dirPath) => (relativePath = '') => join(dirPath, relativePath)

Expand All @@ -8,7 +8,7 @@ export const withDir = (
async (cb) => {
await fs.access(dirPath)

return cb(prefixWithDir(dirPath))
return cb(prefixWithDir(resolve(dirPath)))
}
)
)
Expand All @@ -28,7 +28,7 @@ export const withScratchDir = (

await fs.access(dirPath, fs.constants.W_OK)

return cb(prefixWithDir(dirPath))
return cb(prefixWithDir(resolve(dirPath)))
}
)
)
Expand Down

0 comments on commit 7e91397

Please sign in to comment.