Skip to content

Commit

Permalink
fix(trace viewer): updating default traceStorageDir value (#4962)
Browse files Browse the repository at this point in the history
fix(trace viewer): updating default traceStorageDir value

When `npx playwright show-trace <tracePath>` command is executed, without providing the `resources` optional parameter, the function expected the `traceStorageDir` default value to be the same directory as in which the tracePath resides. This change updates it to the `dirname(tracePath)/trace-resources` if it exists. Such a directory hirerachy is the default that is created when running the tracer in Playwright.
  • Loading branch information
domderen committed Jan 11, 2021
1 parent 56f0120 commit bf64fed
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/cli/traceViewer/traceViewer.ts
Expand Up @@ -137,15 +137,13 @@ export async function showTraceViewer(traceStorageDir: string | undefined, trace
if (!fs.existsSync(tracePath))
throw new Error(`${tracePath} does not exist`);

let files: string[];
if (fs.statSync(tracePath).isFile()) {
files = [tracePath];
if (!traceStorageDir)
traceStorageDir = path.dirname(tracePath);
} else {
files = collectFiles(tracePath);
if (!traceStorageDir)
traceStorageDir = tracePath;
const files: string[] = fs.statSync(tracePath).isFile() ? [tracePath] : collectFiles(tracePath);

if (!traceStorageDir) {
traceStorageDir = fs.statSync(tracePath).isFile() ? path.dirname(tracePath) : tracePath;

if (fs.existsSync(traceStorageDir + '/trace-resources'))
traceStorageDir = traceStorageDir + '/trace-resources';
}

const traceViewer = new TraceViewer(traceStorageDir);
Expand Down

0 comments on commit bf64fed

Please sign in to comment.