Skip to content

Commit 1c87edf

Browse files
committed
use pnpm list for pnpm fixtures
1 parent 09e7ee7 commit 1c87edf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/prepare.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@ const promises = fixtures.map((fixture) =>
8181
await rm(join(cwd, 'package-lock.json'), { force: true })
8282
}
8383

84-
const addPrefix = () =>
85-
new Transform({
84+
const addPrefix = () => {
85+
let isFirstChunk = true
86+
return new Transform({
8687
transform(chunk, encoding, callback) {
88+
if (isFirstChunk) {
89+
this.push(`[${fixture}] `)
90+
isFirstChunk = false
91+
}
8792
this.push(chunk.toString().replace(/\n/gm, `\n[${fixture}] `))
8893
callback()
8994
},
@@ -95,6 +100,7 @@ const promises = fixtures.map((fixture) =>
95100
callback()
96101
},
97102
})
103+
}
98104

99105
console.log(`[${fixture}] Running \`${cmd}\`...`)
100106
const output = execaCommand(cmd, {
@@ -107,7 +113,10 @@ const promises = fixtures.map((fixture) =>
107113
}
108114
output.stderr?.pipe(addPrefix()).pipe(process.stderr)
109115
return output.finally(async () => {
110-
const npmListPromise = execaCommand(`npm list next`, { cwd, stdio: 'pipe', reject: false })
116+
const npmListPromise = execaCommand(
117+
packageManager?.startsWith('pnpm') ? 'pnpm list next' : 'npm list next',
118+
{ cwd, stdio: 'pipe', reject: false },
119+
)
111120
npmListPromise.stdout?.pipe(addPrefix()).pipe(process.stdout)
112121
npmListPromise.stderr?.pipe(addPrefix()).pipe(process.stderr)
113122
await npmListPromise

0 commit comments

Comments
 (0)