Skip to content

Commit

Permalink
Only ignore dfu-util errors when 'File download successfully' is part…
Browse files Browse the repository at this point in the history
… of stdout

Fixes #206
  • Loading branch information
brycekahle committed Feb 11, 2016
1 parent 118b5e3 commit ab3d349
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
9 changes: 1 addition & 8 deletions commands/UpdateCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,7 @@ UpdateCommand.prototype = extend(BaseCommand.prototype, {
steps.push(function (cb) {
var binary = path.resolve(__dirname, '..', 'updates', updates[part]);
whenNode.bindCallback(
dfu.write(binary, part, leave)
.then(null, function (err) {
// don't reject for get_status error
if (err.indexOf('Error during download get_status') >= 0) {
return '';
}
})
.delay(2000)
dfu.write(binary, part, leave).delay(2000)
, cb);
});
first = false;
Expand Down
10 changes: 9 additions & 1 deletion lib/dfu.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ var that = module.exports = {
}

that.checkBinaryAlignment('-D ' + binaryPath);
return utilities.deferredSpawnProcess(cmd, args);
return utilities.deferredSpawnProcess(cmd, args).then(function(output) {
return when.resolve(output.stdout.join('\n'));
}).catch(function(output) {
// If this line is printed, it actually worked. Ignore other errors.
if (output.stdout.indexOf('File downloaded successfully') >= 0) {
return when.resolve(output.stdout.join('\n'));
}
return when.reject(output.stderr.join('\n'));
});
},

getCommand: function () {
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ var that = module.exports = {
}

child.on('close', function (code) {
var output = { stdout: stdout, stderr: errors };
if (!code) {
tmp.resolve(stdout.join('\n'));
tmp.resolve(output);
} else {
tmp.reject(errors.join('\n'));
tmp.reject(output);
}
});
} catch (ex) {
Expand Down

0 comments on commit ab3d349

Please sign in to comment.