From c5805d4e26335b2bd80c405ed43c176e5995b61c Mon Sep 17 00:00:00 2001 From: Misha Kaletsky Date: Fri, 3 Nov 2023 21:22:00 -0400 Subject: [PATCH] use strip-ansi on examples outputs --- test/examples.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/examples.test.ts b/test/examples.test.ts index 94b4363f..3ff88ca7 100644 --- a/test/examples.test.ts +++ b/test/examples.test.ts @@ -1,6 +1,7 @@ import fs = require('fs'); import path = require('path'); import childProcess = require('child_process'); +import stripAnsi = require('strip-ansi'); const examplesDir = path.join(__dirname, '../examples'); const examples = fs.readdirSync(examplesDir).filter(ex => /^\d/.exec(ex)); @@ -28,6 +29,7 @@ examples.forEach(ex => { .filter(Boolean) .flatMap(cmd => { let output = childProcess.execSync(`sh -c "${cmd} 2>&1"`, { cwd: dir }).toString().trim(); + output = stripAnsi(output); output = cmd.startsWith('npm') || cmd.endsWith('--help') ? '...' : output; // npm commands and `--help` are formatted inconsistently and aren't v relevant output = output.split(process.cwd()).join('<>'); // cwd varies by machine output = output.replace(/durationSeconds: .*/g, 'durationSeconds: ???'); // migrations durations vary by a few milliseconds