Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow to pipe stdin to exec command
This is the equivalent of:

```
echo '...' | node ./my-command.js
```
  • Loading branch information
RobinMalfait committed Jan 16, 2025
commit cbc9b75589c12c0628495627f4e8370ddb7dcf90
7 changes: 6 additions & 1 deletion integrations/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface ChildProcessOptions {

interface ExecOptions {
ignoreStdErr?: boolean
stdin?: string
}

interface TestConfig {
Expand Down Expand Up @@ -112,7 +113,7 @@ export function test(
}
if (debug) console.log(`> ${command}`)
return new Promise((resolve, reject) => {
exec(
let child = exec(
command,
{
cwd,
Expand All @@ -134,6 +135,10 @@ export function test(
}
},
)
if (execOptions.stdin) {
child.stdin?.write(execOptions.stdin)
child.stdin?.end()
}
})
},
async spawn(command: string, childProcessOptions: ChildProcessOptions = {}) {
Expand Down