Skip to content

fix(powershell): support pipeline input with Invoke-Expression #8297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025

Conversation

alexsch01
Copy link
Contributor

@alexsch01 alexsch01 commented May 15, 2025

needs this PR first: #8278


fixes the case with Invoke-Expression and pipeline input to work

"Line 1", "Line 2", "Line 3" | npm start

above syntax ONLY works in PowerShell

OUTPUT


> start
> node script.js

Processed: Line 1
Processed: Line 2
Processed: Line 3

given.....

[package.json]

{
  "scripts": {
    "start": "node script.js"
  }
}

[script.js]

const readline = require('readline')

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
})

rl.on('line', (line) => {
  console.log(`Processed: ${line}`)
})

manually tested with PowerShell

@alexsch01 alexsch01 requested a review from a team as a code owner May 15, 2025 16:01
@wraithgar wraithgar merged commit 8794fd9 into npm:latest May 15, 2025
29 checks passed
alexsch01 added a commit to alexsch01/cli that referenced this pull request May 15, 2025
@alexsch01 alexsch01 deleted the version2 branch May 15, 2025 18:51
@alexsch01 alexsch01 mentioned this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants