From 40387ad5c01c442c893be73e7246b470e3c2f730 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Tue, 30 Apr 2024 14:24:18 -0600 Subject: [PATCH 1/2] fix: use require.cache to resolve root --- src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9d469dc..123a665 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,12 +15,14 @@ function traverseFilePathUntil(filename: string, predicate: (filename: string) = return current } -// Update to path.dirname(url.fileURLToPath(import.meta.url)) whenever we migrate to ESM /* eslint-disable unicorn/prefer-module */ -loadConfig.root = traverseFilePathUntil( - require.main?.path ?? module.path, - (p) => !(p.includes('node_modules') || p.includes('.pnpm') || p.includes('.yarn')), -) +loadConfig.root = + process.env.OCLIF_TEST_ROOT ?? + Object.values(require.cache).find((m) => m?.children.includes(module))?.filename ?? + traverseFilePathUntil( + require.main?.path ?? module.path, + (p) => !(p.includes('node_modules') || p.includes('.pnpm') || p.includes('.yarn')), + ) /* eslint-enable unicorn/prefer-module */ // Using a named export to import fancy causes this issue: https://github.com/oclif/test/issues/516 From 7eb1051bc2f7a250806d72ab39f982c01c90c2f5 Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Tue, 30 Apr 2024 20:28:34 +0000 Subject: [PATCH 2/2] chore(release): 3.2.12-dev.0 [skip ci] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dfc07cb..dac23d2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@oclif/test", "description": "test helpers for oclif components", - "version": "3.2.11", + "version": "3.2.12-dev.0", "author": "Salesforce", "bugs": "https://github.com/oclif/test/issues", "dependencies": {