Skip to content

Commit

Permalink
stream: decouple from stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Oct 21, 2015
1 parent 08dd33e commit 9c22ca3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const http = require('http')
process.env.NODE_ENV = 'development'

const server = http.createServer()
server.listen(1337, serverSummary(server))
server.listen(1337, serverSummary(server).pipe(process.stdout))
```

## Why?
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ function summary (server) {
const env = process.env.NODE_ENV || 'undefined'

const serialize = ndjson.serialize()
serialize.pipe(process.stdout)

serialize.write({name: 'url', url: url, type: 'connect'})
serialize.write({name: 'port', message: port})
serialize.write({name: 'env', message: env})
serialize.write({name: 'pid', message: process.pid})
serialize.end()

return serialize
}
}
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('should log console output', function (t) {
const server = http.createServer()
server.listen(null, function () {
const sum = summary(server)
sum()
sum().pipe(process.stdout)
t.pass('server called')
server.close()
})
Expand Down

0 comments on commit 9c22ca3

Please sign in to comment.