From 414a4c3ef04c350a703f740af487027ec65fbcec Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sat, 5 Aug 2023 09:01:27 -0700 Subject: [PATCH] chore: pass color through in web server commands (#24619) --- package-lock.json | 6 +++++- packages/playwright-test/src/plugins/webServerPlugin.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b159ec624..4ab4ff905d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/packages/playwright-test/src/plugins/webServerPlugin.ts b/packages/playwright-test/src/plugins/webServerPlugin.ts index 6a518d9f98..cfff7ad441 100644 --- a/packages/playwright-test/src/plugins/webServerPlugin.ts +++ b/packages/playwright-test/src/plugins/webServerPlugin.ts @@ -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()); }); }