diff --git a/src/utils/DockerMachineUtil.js b/src/utils/DockerMachineUtil.js index 4f8a8e3b..9d2097f8 100644 --- a/src/utils/DockerMachineUtil.js +++ b/src/utils/DockerMachineUtil.js @@ -24,11 +24,11 @@ var DockerMachine = { version: function () { return util.exec([this.command(), '-v']).then(stdout => { try { - var match = stdout.match(/(\d+\.\d+\.\d+).*/); - if (!match || match.length < 2) { + var matchlist = stdout.match(/(\d+\.\d+\.\d+).*/); + if (!matchlist || matchlist.length < 2) { Promise.reject('docker-machine -v output format not recognized.'); } - return Promise.resolve(match[1]); + return Promise.resolve(matchlist[1]); } catch (err) { return Promise.resolve(null); } @@ -160,11 +160,13 @@ var DockerMachine = { }, virtualBoxLogs: function (machineName = this.name()) { let logsPath = path.join(util.home(), '.docker', 'machine', 'machines', machineName, machineName, 'Logs', 'VBox.log'); - if (fs.existsSync(logsPath)) { - return fs.readFileSync(logsPath, 'utf8'); - } else { - return null; + let logData = null; + try { + logData = fs.readFileSync(logsPath, 'utf8'); + } catch (e) { + console.error(e); } + return logData; } }; diff --git a/src/utils/VirtualBoxUtil.js b/src/utils/VirtualBoxUtil.js index 2350da9e..2768eecc 100644 --- a/src/utils/VirtualBoxUtil.js +++ b/src/utils/VirtualBoxUtil.js @@ -23,11 +23,11 @@ var VirtualBox = { }, version: function () { return util.exec([this.command(), '-v']).then(stdout => { - var match = stdout.match(/(\d+\.\d+\.\d+).*/); - if (!match || match.length < 2) { + let matchlist = stdout.match(/(\d+\.\d+\.\d+).*/); + if (!matchlist || matchlist.length < 2) { Promise.reject('VBoxManage -v output format not recognized.'); } - return Promise.resolve(match[1]); + return Promise.resolve(matchlist[1]); }).catch(() => { return Promise.resolve(null); });