Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 8 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ async function report(app, timeout) {
finish = resolve
})

const ended = lines(app.stdout, (line) => {
console.log(line)
app
.on('stdout', (line) => {
console.log(line)

result.push(line)
result.push(line)

if (result.done) finish()
})

lines(app.stderr, (line) => comment(line))
if (result.done) finish()
})
.on('stderr', (line) => comment(line))

Promise.all([app.exited, ended]).then(finish)
Promise.all([app.exited, app.ended]).then(finish)

// Each case has a timeout of its own, so this only catches a stalled run.
const timer = setTimeout(() => {
Expand Down Expand Up @@ -219,27 +219,6 @@ async function report(app, timeout) {
return result
}

function lines(stream, online) {
return new Promise((resolve) => {
let buffered = ''

stream
.setEncoding('utf8')
.on('data', (data) => {
const parts = (buffered + data).split(/\r?\n/)

buffered = parts.pop()

for (const line of parts) online(line)
})
.on('end', () => {
if (buffered !== '') online(buffered)

resolve()
})
})
}

// A platform that does not report how an app exits leaves both unset. Windows
// reports a crash as an NTSTATUS code, which is looked up in hex.
function status({ code, signal }) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"homepage": "https://github.com/holepunchto/bare-native-test#readme",
"dependencies": {
"bare-device": "^0.1.11",
"bare-device": "^0.1.14",
"bare-fs": "^4.8.2",
"bare-module-resolve": "^1.12.6",
"bare-path": "^3.1.2",
Expand Down
Loading