chore: pass color through in web server commands (#24619)

This commit is contained in:
Pavel Feldman 2023-08-05 09:01:27 -07:00 committed by GitHub
parent 120de62798
commit 414a4c3ef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

6
package-lock.json generated
View File

@ -6563,7 +6563,8 @@
},
"packages/playwright-grid": {
"name": "@playwright/experimental-grid",
"version": "1.37.0-next",
"version": "0.0.1",
"license": "Apache-2.0",
"dependencies": {
"commander": "^11.0.0",
"debug": "^4.3.2",
@ -6577,6 +6578,9 @@
"@types/debug": "^4.1.8",
"@types/ws": "^8.5.5",
"playwright-core": "1.37.0-next"
},
"engines": {
"node": ">=16"
}
},
"packages/playwright-grid/node_modules/commander": {

View File

@ -16,7 +16,7 @@
import path from 'path';
import net from 'net';
import { debug } from 'playwright-core/lib/utilsBundle';
import { colors, debug } from 'playwright-core/lib/utilsBundle';
import { raceAgainstDeadline, launchProcess, httpRequest, monotonicTime } from 'playwright-core/lib/utils';
import type { FullConfig } from '../../types/testReporter';
@ -40,6 +40,8 @@ export type WebServerPluginOptions = {
const DEFAULT_ENVIRONMENT_VARIABLES = {
'BROWSER': 'none', // Disable that create-react-app will open the page in the browser
'FORCE_COLOR': '1',
'DEBUG_COLORS': '1',
};
const debugWebServer = debug('pw:webserver');
@ -112,11 +114,12 @@ export class WebServerPlugin implements TestRunnerPlugin {
launchedProcess.stderr!.on('data', line => {
if (debugWebServer.enabled || (this._options.stderr === 'pipe' || !this._options.stderr))
this._reporter!.onStdErr?.('[WebServer] ' + line.toString());
this._reporter!.onStdErr?.(colors.dim('[WebServer] ') + line.toString());
});
launchedProcess.stdout!.on('data', line => {
process.stdout.write(line);
if (debugWebServer.enabled || this._options.stdout === 'pipe')
this._reporter!.onStdOut?.('[WebServer] ' + line.toString());
this._reporter!.onStdOut?.(colors.dim('[WebServer] ') + line.toString());
});
}