Skip to content

Commit

Permalink
reverting a style change I made and better comments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithan committed Oct 30, 2019
1 parent 46fd1de commit 1893934
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cmd/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ const ensureError = require('../lib/utilities').ensureError;
const cmd = path.basename(process.argv[1]);
const arrow = chalk.green('>');
const alert = chalk.yellow('!');
const timeoutError = 'Serial timed out';

function protip(){
const args = Array.prototype.slice.call(arguments);
args.unshift(chalk.cyan('!'), chalk.bold.white('PROTIP:'));
console.log.apply(null, args);
}

const TIMEOUT_ERROR_MESSAGE = 'Serial timed out';

// An LTE device may take up to 18 seconds to power up the modem
const MODULE_INFO_COMMAND_TIMEOUT = 20000;
Expand Down Expand Up @@ -617,7 +617,7 @@ module.exports = class SerialCommand {
return !!matches;
})
.catch((err) => {
if (err !== TIMEOUT_ERROR_MESSAGE){
if (err !== timeoutError){
throw err;
}
return false;
Expand Down Expand Up @@ -898,7 +898,7 @@ module.exports = class SerialCommand {
}

function startTimeout(to){
self._serialTimeout = setTimeout(() => reject(TIMEOUT_ERROR_MESSAGE), to);
self._serialTimeout = setTimeout(() => reject(timeoutError), to);
}

function resetTimeout(){
Expand Down Expand Up @@ -1228,7 +1228,7 @@ module.exports = class SerialCommand {
reject('Serial port closed early');
}

function startTimeout(to, message = TIMEOUT_ERROR_MESSAGE){
function startTimeout(to, message = timeoutError){
self._serialTimeout = setTimeout(() => {
reject(message);
}, to);
Expand Down Expand Up @@ -1319,7 +1319,7 @@ module.exports = class SerialCommand {
serialPort.pipe(parser);

const failTimer = setTimeout(() => {
reject(TIMEOUT_ERROR_MESSAGE);
reject(timeoutError);
}, failDelay);

parser.on('data', (data) => {
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/serial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ describe('Serial Command', () => {
const mockSerial = new MockSerial();
serial.serialPort = mockSerial;
const wifiPromise = serial._serialWifiConfig(device);
// This allows _serialWifiConfig's internal promises to run and try to
// connect to the serial device before moving time forward.
process.nextTick(() => {
clock.tick(5010);
});
Expand Down

0 comments on commit 1893934

Please sign in to comment.