(handler)
| 175 | }); |
| 176 | |
| 177 | function createLineHandler(handler) { |
| 178 | let buffer = ''; |
| 179 | return (data) => { |
| 180 | const text = buffer + data.toString('utf8'); |
| 181 | const lines = text.split('\n'); |
| 182 | buffer = lines.pop(); |
| 183 | lines.forEach((line) => { |
| 184 | if (line) handler(line); |
| 185 | }); |
| 186 | }; |
| 187 | } |
| 188 | |
| 189 | child.stdout.on('data', createLineHandler(stdOutLineHandler)); |
| 190 | child.stderr.on('data', createLineHandler(stdOutLineHandler)); |