From b847d2f1a42b625c26149f4a2029ed00a1edf90b Mon Sep 17 00:00:00 2001 From: fflorent Date: Thu, 7 Aug 2025 19:53:53 +0200 Subject: [PATCH] Fix use of tmp.dir() with `dir` option --- lib/tmp.js | 2 +- test/inband-standard.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tmp.js b/lib/tmp.js index 162dca1..e6b9bcb 100644 --- a/lib/tmp.js +++ b/lib/tmp.js @@ -466,7 +466,7 @@ function _resolvePath(name, tmpDir, cb) { cb(null, path.join(parentDir, path.basename(pathToResolve))); }); } else { - fs.realpath(path, cb); + fs.realpath(pathToResolve, cb); } }); } diff --git a/test/inband-standard.js b/test/inband-standard.js index 3b5e5d5..79d1b24 100644 --- a/test/inband-standard.js +++ b/test/inband-standard.js @@ -3,6 +3,7 @@ var fs = require('fs'), + os = require('os'), path = require('path'), assertions = require('./assertions'), tmp = require('../lib/tmp'); @@ -18,6 +19,7 @@ module.exports = function inbandStandard(isFile, beforeHook, sync = false) { describe('with mode', inbandStandardTests(null, { mode: 0o755 }, isFile, beforeHook, sync)); describe('with multiple options', inbandStandardTests(null, { prefix: 'tmp-multiple', postfix: 'bar', mode: 0o750 }, isFile, beforeHook, sync)); describe('with tmpdir option', inbandStandardTests(null, { tmpdir: path.join(tmp.tmpdir, 'tmp-external'), mode: 0o750 }, isFile, beforeHook, sync)); + describe('with dir option', inbandStandardTests(null, { dir: os.tmpdir(), mode: 0o750 }, isFile, beforeHook, sync)); if (isFile) { describe('with discardDescriptor', inbandStandardTests(null, { mode: testMode, discardDescriptor: true }, isFile, beforeHook, sync)); describe('with detachDescriptor', inbandStandardTests(null, { mode: testMode, detachDescriptor: true }, isFile, beforeHook, sync));