chore: make generated report writable (#18750)

Fixes: https://github.com/microsoft/playwright/issues/18747
This commit is contained in:
Pavel Feldman 2022-11-13 12:46:35 -08:00 committed by GitHub
parent 1b13519984
commit 8e882fdd58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -46,3 +46,8 @@ export function canAccessFile(file: string) {
return false; return false;
} }
} }
export async function copyFileAndMakeWritable(from: string, to: string) {
await fs.promises.copyFile(from, to);
await fs.promises.chmod(to, 0o664);
}

View file

@ -23,7 +23,7 @@ import { Transform } from 'stream';
import type { FullConfig, Suite } from '../../types/testReporter'; import type { FullConfig, Suite } from '../../types/testReporter';
import { HttpServer } from 'playwright-core/lib/utils/httpServer'; import { HttpServer } from 'playwright-core/lib/utils/httpServer';
import { assert, calculateSha1 } from 'playwright-core/lib/utils'; import { assert, calculateSha1 } from 'playwright-core/lib/utils';
import { removeFolders } from 'playwright-core/lib/utils/fileUtils'; import { copyFileAndMakeWritable, removeFolders } from 'playwright-core/lib/utils/fileUtils';
import type { JsonAttachment, JsonReport, JsonSuite, JsonTestCase, JsonTestResult, JsonTestStep } from './raw'; import type { JsonAttachment, JsonReport, JsonSuite, JsonTestCase, JsonTestResult, JsonTestStep } from './raw';
import RawReporter from './raw'; import RawReporter from './raw';
import { stripAnsiEscapes } from './base'; import { stripAnsiEscapes } from './base';
@ -272,7 +272,7 @@ class HtmlBuilder {
// Copy app. // Copy app.
const appFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'htmlReport'); const appFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'htmlReport');
fs.copyFileSync(path.join(appFolder, 'index.html'), path.join(this._reportFolder, 'index.html')); await copyFileAndMakeWritable(path.join(appFolder, 'index.html'), path.join(this._reportFolder, 'index.html'));
// Copy trace viewer. // Copy trace viewer.
if (this._hasTraces) { if (this._hasTraces) {
@ -282,7 +282,7 @@ class HtmlBuilder {
for (const file of fs.readdirSync(traceViewerFolder)) { for (const file of fs.readdirSync(traceViewerFolder)) {
if (file.endsWith('.map')) if (file.endsWith('.map'))
continue; continue;
fs.copyFileSync(path.join(traceViewerFolder, file), path.join(traceViewerTargetFolder, file)); await copyFileAndMakeWritable(path.join(traceViewerFolder, file), path.join(traceViewerTargetFolder, file));
} }
} }