Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Small fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Oct 22, 2017
1 parent f20e86a commit f3fe73d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
##### 2.0.11 - 22 October 2017

###### Bug fixes
- Fix to `spawnAsyncWithIO`

##### 2.0.10 - 17 October 2017

###### Backwards compatible changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@google-cloud/nodejs-repo-tools",
"version": "2.0.10",
"version": "2.0.11",
"description": "Tools used to maintain and test Node.js repositories in the GoogleCloudPlaftorm organization.",
"author": "Google Inc.",
"license": "Apache-2.0",
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Expand Up @@ -76,6 +76,12 @@ exports.runAsyncWithIO = (cmd, cwd, cb) => {
};

exports.spawnAsyncWithIO = (cmd, args, cwd, debug) => {
args || (args = []);
let opts = debug;
if (typeof opts === 'boolean') {
opts = { debug: true };
}
opts || (opts = {});
return new Promise((resolve, reject) => {
let done = false;
let stdout = '';
Expand All @@ -98,15 +104,18 @@ exports.spawnAsyncWithIO = (cmd, args, cwd, debug) => {
}
}

if (debug || (debug !== false && process.env.DEBUG)) {
utils.logger.log('CMD', cmd, ...args);
}
const child = childProcess.spawn(cmd, args, { cwd: cwd, shell: true });
child.stdout.on('data', (chunk) => {
if (debug || (debug !== false && process.env.DEBUG)) {
utils.logger.log(chunk.toString());
utils.logger.log('stdout', chunk.toString());
}
stdout += chunk.toString();
});
child.stderr.on('data', (chunk) => {
utils.logger.error(chunk.toString());
utils.logger.error('stderr', chunk.toString());
stderr += chunk.toString();
});
child
Expand Down

0 comments on commit f3fe73d

Please sign in to comment.