Skip to content

Commit c7c47f2

Browse files
committed
Update main.js
1 parent 4f6913e commit c7c47f2

1 file changed

Lines changed: 1 addition & 25 deletions

File tree

bin/main.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,7 @@ module.exports = function main (source, outDir, args) {
5050
})
5151
const parts = parseShellQuote(command, env)
5252
const child = spawn(parts[0], parts.slice(1), { env })
53-
const outer = new Duplex({
54-
write(chunk, encoding, callback) {
55-
if (!child.stdin.write(chunk, encoding)) {
56-
child.stdin.once('drain', callback)
57-
} else {
58-
callback()
59-
}
60-
},
61-
read(size) {
62-
const chunk = child.stdout.read(size)
63-
if (chunk !== null) {
64-
this.push(chunk)
65-
} else {
66-
child.stdout.once('readable', () => {
67-
const chunk = child.stdout.read(size)
68-
if (chunk !== null) this.push(chunk)
69-
})
70-
}
71-
},
72-
destroy(err, callback) {
73-
child.stdin.destroy(err)
74-
child.stdout.destroy(err)
75-
callback(err)
76-
},
77-
})
53+
const outer = Duplex.from({ readable: child.stdout, writable: child.stdin })
7854
child.stdout.on('end', () => outer.push(null))
7955
child.on('exit', code => {
8056
if (code !== 0) {

0 commit comments

Comments
 (0)