From b02c561c317f092f1fc3cd482ef6a1e728b32ec7 Mon Sep 17 00:00:00 2001 From: nlf Date: Thu, 2 Mar 2023 12:42:14 -0800 Subject: [PATCH] fix: fallback to node.path if fs.mkdir returns undefined --- workspaces/arborist/lib/arborist/reify.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 87993cca876d6..7cc339b118d54 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -535,7 +535,9 @@ module.exports = cls => class Reifier extends cls { await this[_renamePath](d, retired) } } - const made = await mkdir(node.path, { recursive: true }) + // fs.mkdir will return undefined if the path already exists. if that happens + // then node.path is the sparse tree root + const made = await mkdir(node.path, { recursive: true }) || node.path this[_sparseTreeDirs].add(node.path) this[_sparseTreeRoots].add(made) }))