From 7e913977561ab89013909a2a922c000b4e3191c8 Mon Sep 17 00:00:00 2001 From: Fabien Schurter Date: Mon, 6 May 2024 19:46:19 +0200 Subject: [PATCH] fix: Use absolute path in `#src/utils/fs.with*Dir()` functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will avoid problems when an absolute path is mandatory, for example when using JavaScript’s built-in `import()` function. --- src/utils/fs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/fs.js b/src/utils/fs.js index b2e2230..f23ff3a 100644 --- a/src/utils/fs.js +++ b/src/utils/fs.js @@ -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) @@ -8,7 +8,7 @@ export const withDir = ( async (cb) => { await fs.access(dirPath) - return cb(prefixWithDir(dirPath)) + return cb(prefixWithDir(resolve(dirPath))) } ) ) @@ -28,7 +28,7 @@ export const withScratchDir = ( await fs.access(dirPath, fs.constants.W_OK) - return cb(prefixWithDir(dirPath)) + return cb(prefixWithDir(resolve(dirPath))) } ) )