Skip to content

Commit

Permalink
🎨 Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Mar 31, 2018
1 parent eeb0205 commit 91ec715
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,27 @@ exports.exec = function(command, params) {
// Stdout
stdout.on('data', data => metadata.push(data));
stdout.on('close', () => {
// Decode data use utf16le
let data = Buffer.concat(metadata).toString('utf16le');
// Only parse when no error
if (!errors.length) {
// Decode data use utf16le
let data = Buffer.concat(metadata).toString('utf16le');

try {
// Parse json data
data = JSON.parse(data);
} catch (error) {
return reject(data);
}
try {
// Parse json data
data = JSON.parse(data);
} catch (error) {
return reject(data);
}

// Is valid json
resolve(data);
// Is valid json
resolve(data);
}
});

// Stderr
stderr.on('data', data => errors.push(data));
stderr.on('close', () => {
// Only reject when with error
if (errors.length) {
reject(new Error(Buffer.concat(errors).toString('utf16le')));
}
Expand Down

0 comments on commit 91ec715

Please sign in to comment.