From f5c73a9a7f40875d83ad56eda8a21f520a5eeaf1 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Fri, 15 Nov 2024 09:56:00 +0100 Subject: [PATCH] Update `pnpm pack` output parsing in `__tests__/e2e.test.ts` * Split the lines and match the line by the `preflight-...` pattern * Remove the intermediary `pnpmPackOutput` variable and wrap the await expression in parentheses * Use a more forgiving regex pattern for matching `preflight-...` * Add error handling for missing tarball path in `pnpm pack` output --- __tests__/e2e.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/__tests__/e2e.test.ts b/__tests__/e2e.test.ts index 81d327d4..7a096748 100644 --- a/__tests__/e2e.test.ts +++ b/__tests__/e2e.test.ts @@ -7,7 +7,14 @@ const fixturesTempDir = '__tests__/fixtures/__temp'; beforeAll( async () => { // Pack and install Preflight globally - const { stdout: pnpmPackTarballPath } = await execa`pnpm pack`; + const pnpmPackTarballPath = (await execa`pnpm pack`).stdout + .split('\n') + .find((line) => line.match(/^preflight-.*\.tgz$/)); + + if (!pnpmPackTarballPath) { + throw new Error('Failed to find the tarball path in `pnpm pack` output'); + } + await execa`pnpm add --global ${process.cwd()}/${pnpmPackTarballPath}`; await pMap(