Skip to content
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

feat: let $ be piped from stream #953

Merged
merged 1 commit into from
Nov 24, 2024
Merged

Conversation

antongolub
Copy link
Collaborator

continues #949

const getUpperCaseTransform = () =>
  new Transform({
    transform(chunk, encoding, callback) {
      callback(null, String(chunk).toUpperCase())
    },
  })
  
// $ > stream (promisified) > $ 
const o1 = await $`echo "hello"`
   .pipe(getUpperCaseTransform())
   .pipe($`cat`)
   
o1.stdout //  'HELLO\n'

// stream > $
const file = tempfile()
await fs.writeFile(file, 'test')
const o2 = await fs
  .createReadStream(file)
  .pipe(getUpperCaseTransform())
  .pipe($`cat`)
  
o2.stdout //  'TEST'

@antongolub antongolub requested a review from antonmedv November 24, 2024 13:37
@antonmedv antonmedv merged commit 4bb470b into google:main Nov 24, 2024
21 checks passed
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