Skip to content

Commit e23d250

Browse files
committed
Attempt to make module resolution for sample app more robust
Refs: #7570
1 parent 5871663 commit e23d250

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

packages/tools/visual-tests/src/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@ if (!tempDir) {
1919
process.env.THEME_MODULE = path.join(process.cwd(), process.env.THEME_MODULE); // Use current working directory (i.e. the theme folder) to complete module path
2020
const visualsTestModulePath = fileURLToPath(new URL('..', import.meta.url));
2121
const binaryPath = fileURLToPath(new URL('../node_modules/.bin', import.meta.url));
22-
23-
let sampleReactPath = '../node_modules/@public-ui/visual-tests/node_modules/@public-ui/sample-react';
24-
let backSteps = ``;
25-
let workingDir = null;
26-
do {
27-
const url = new URL(backSteps + sampleReactPath, import.meta.url);
28-
workingDir = fileURLToPath(url);
29-
backSteps += `../`;
30-
} while (!fs.existsSync(workingDir) && path.resolve(process.cwd(), backSteps) !== '/');
22+
const sampleReactPackageJsonPath = import.meta.resolve('@public-ui/sample-react/package.json');
23+
const workingDir = fileURLToPath(path.dirname(sampleReactPackageJsonPath));
3124

3225
if (!fs.existsSync(workingDir)) {
3326
throw new Error('Could not find React Sample App package. Please install it with "npm install @public-ui/sample-react".');

0 commit comments

Comments
 (0)