From 0005dd9fce1a980319b6013176f84cbb78dc2d2d Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Thu, 28 Dec 2023 13:37:47 -0500 Subject: [PATCH] Improve testEnvPath construction in main.test.js After thinking about it, I realized the regular expression replacement method wasn't quite right. Then I realized there was a pretty way of removing the jsdoc path via split(), filter(), and join(). --- test/main.test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/main.test.js b/test/main.test.js index 087cdd3..42d0889 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -49,9 +49,10 @@ describe('jsdoc-cli-wrapper', () => { try { const jsdocPath = await getPath('jsdoc', process.env, process.platform) - const jsdocDir = path.dirname(jsdocPath).replaceAll('\\', '\\\\') - const pat = new RegExp(`${path.delimiter}?${jsdocDir}${path.delimiter}?`) - testEnvPath = testEnvPath.replace(pat, '') + const jsdocDir = path.dirname(jsdocPath) + testEnvPath = testEnvPath.split(path.delimiter) + .filter(p => p !== jsdocDir) + .join(path.delimiter) } catch { /* It's OK if it's not actually installed. */ } return spawnMain(testEnvPath, ...argv)