Skip to content

feat: let $ be piped from stream#953

Merged
antonmedv merged 1 commit intogoogle:mainfrom
antongolub:pipe-from-stream
Nov 24, 2024
Merged

feat: let $ be piped from stream#953
antonmedv merged 1 commit intogoogle:mainfrom
antongolub:pipe-from-stream

Conversation

@antongolub
Copy link
Copy Markdown
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
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