From 884a36179eb193c6b79be39b80433359b9ae2fac Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 7 Apr 2020 01:05:54 +0200 Subject: [PATCH] packages/cli: avoid clearing screen in app-serve --- packages/cli/src/commands/app/serve.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/app/serve.ts b/packages/cli/src/commands/app/serve.ts index 86ca6b97d3..51806aa9d6 100644 --- a/packages/cli/src/commands/app/serve.ts +++ b/packages/cli/src/commands/app/serve.ts @@ -14,18 +14,29 @@ * limitations under the License. */ -import { run } from 'helpers/run'; +import { spawn } from 'child_process'; +import { waitForExit } from 'helpers/run'; import { watchDeps } from 'commands/watch-deps'; +import { createLogger } from 'commands/watch-deps/logger'; export default async () => { - const args = ['start']; - // Start dynamic watch and build of dependencies, then serve the app await watchDeps({ build: true }); - await run('react-scripts', args, { + + const child = spawn('react-scripts', ['start'], { env: { + FORCE_COLOR: 'true', EXTEND_ESLINT: 'true', SKIP_PREFLIGHT_CHECK: 'true', + ...process.env, }, + stdio: ['inherit', 'pipe', 'inherit'], + shell: true, }); + + // We need to avoid clearing the terminal, or the build feedback of dependencies will be lost + const log = createLogger(); + child.stdout.setEncoding('utf8'); + child.stdout!.on('data', log.out); + await waitForExit(child); };