Skip to content

Commit

Permalink
Merge pull request #9 from SahinVardar/master
Browse files Browse the repository at this point in the history
Added the ability to stream 'stdout' and 'stderr' from docker command.
  • Loading branch information
mattqs authored Aug 26, 2019
2 parents 78c724a + 2cd8af5 commit 2a8209f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class Docker {
//console.log('execCommand =', execCommand);
//console.log('exec options =', execOptions);

exec(execCommand, execOptions, function(error, stdout, stderr) {
const childProcess = exec(execCommand, execOptions, function(error, stdout, stderr) {
if (error) {
const message = `error: '${error}' stdout = '${stdout}' stderr = '${stderr}'`;
reject(message);
Expand All @@ -217,6 +217,15 @@ export class Docker {
//doesn't work otherwise for 'build - t nginximg1 .'
resolve({ result: stdout});
});

childProcess.stdout.on("data", (chunk) => {
process.stdout.write( chunk.toString() );
});

childProcess.stderr.on("data", (chunk) => {
process.stderr.write( chunk.toString() );
});

});
}).then(function(data: any) {
//console.log('data:', data);
Expand Down

0 comments on commit 2a8209f

Please sign in to comment.