From 729cfbba14ba83e8930abe61f0a3593d6a47a6e5 Mon Sep 17 00:00:00 2001 From: nlf Date: Thu, 2 Mar 2023 12:42:14 -0800 Subject: [PATCH] fix: only add directories we made to _sparseTreeRoots --- workspaces/arborist/lib/arborist/reify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 87993cca876d6..760fa977ecfd9 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -535,9 +535,14 @@ module.exports = cls => class Reifier extends cls { await this[_renamePath](d, retired) } } - const made = await mkdir(node.path, { recursive: true }) this[_sparseTreeDirs].add(node.path) - this[_sparseTreeRoots].add(made) + const made = await mkdir(node.path, { recursive: true }) + // if the directory already exists, made will be undefined. if that's the case + // we don't want to remove it because we aren't the ones who created it so we + // omit it from the _sparseTreeRoots + if (made) { + this[_sparseTreeRoots].add(made) + } })) .then(() => process.emit('timeEnd', 'reify:createSparse')) }