diff --git a/lib/browser/app.js b/lib/browser/app.js index b14065b5..252f2155 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -118,7 +118,7 @@ app.controller('AppController', function( WindowProgressService.set(state.progress); }); - this.scanner.start(2000).on('scan', function(drives) { + this.scanner.start(2000).on('error', dialog.showError).on('scan', function(drives) { // Notice we only autoselect the drive if there is an image, // which means that the first step was completed successfully, diff --git a/lib/browser/modules/drive-scanner.js b/lib/browser/modules/drive-scanner.js index d22b7beb..8f6b3ea4 100644 --- a/lib/browser/modules/drive-scanner.js +++ b/lib/browser/modules/drive-scanner.js @@ -23,17 +23,8 @@ const angular = require('angular'); const _ = require('lodash'); const EventEmitter = require('events').EventEmitter; -const electron = require('electron'); const drivelist = require('drivelist'); -if (window.mocha) { - var path = require('path'); - var srcPath = path.join(__dirname, '..', '..', 'src'); - var dialog = electron.remote.require(path.join(srcPath, 'dialog')); -} else { - var dialog = electron.remote.require('./src/dialog'); -} - const driveScanner = angular.module('Etcher.drive-scanner', []); driveScanner.service('DriveScannerService', function($q, $interval, $timeout) { @@ -141,7 +132,9 @@ driveScanner.service('DriveScannerService', function($q, $interval, $timeout) { return self.scan().then(function(drives) { emitter.emit('scan', drives); self.setDrives(drives); - }).catch(dialog.showError); + }).catch(function(error) { + emitter.emit('error', error); + }); }; // Make sure any pending interval is cancelled