Skip to content

Commit 2a8209f

Browse files
authored
Merge pull request #9 from SahinVardar/master
Added the ability to stream 'stdout' and 'stderr' from docker command.
2 parents 78c724a + 2cd8af5 commit 2a8209f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class Docker {
208208
//console.log('execCommand =', execCommand);
209209
//console.log('exec options =', execOptions);
210210

211-
exec(execCommand, execOptions, function(error, stdout, stderr) {
211+
const childProcess = exec(execCommand, execOptions, function(error, stdout, stderr) {
212212
if (error) {
213213
const message = `error: '${error}' stdout = '${stdout}' stderr = '${stderr}'`;
214214
reject(message);
@@ -217,6 +217,15 @@ export class Docker {
217217
//doesn't work otherwise for 'build - t nginximg1 .'
218218
resolve({ result: stdout});
219219
});
220+
221+
childProcess.stdout.on("data", (chunk) => {
222+
process.stdout.write( chunk.toString() );
223+
});
224+
225+
childProcess.stderr.on("data", (chunk) => {
226+
process.stderr.write( chunk.toString() );
227+
});
228+
220229
});
221230
}).then(function(data: any) {
222231
//console.log('data:', data);

0 commit comments

Comments
 (0)