mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-25 12:16:37 +00:00
Refactor Etcher using ES6 features
This commit is contained in:
parent
f7ddce3000
commit
122f136ff8
@ -59,7 +59,7 @@
|
|||||||
"evil" : false, // Tolerate use of `eval`.
|
"evil" : false, // Tolerate use of `eval`.
|
||||||
"expr" : true, // Tolerate `ExpressionStatement` as Programs.
|
"expr" : true, // Tolerate `ExpressionStatement` as Programs.
|
||||||
"funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
|
"funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
|
||||||
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
"globalstrict" : true, // Allow global "use strict" (also enables 'strict').
|
||||||
"iterator" : false, // Allow usage of __iterator__ property.
|
"iterator" : false, // Allow usage of __iterator__ property.
|
||||||
"lastsemic" : false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
|
"lastsemic" : false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
|
||||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||||
|
20
gulpfile.js
20
gulpfile.js
@ -14,13 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var gulp = require('gulp');
|
'use strict';
|
||||||
var jscs = require('gulp-jscs');
|
|
||||||
var jshint = require('gulp-jshint');
|
|
||||||
var jshintStylish = require('jshint-stylish');
|
|
||||||
var sass = require('gulp-sass');
|
|
||||||
|
|
||||||
var paths = {
|
const gulp = require('gulp');
|
||||||
|
const jscs = require('gulp-jscs');
|
||||||
|
const jshint = require('gulp-jshint');
|
||||||
|
const jshintStylish = require('jshint-stylish');
|
||||||
|
const sass = require('gulp-sass');
|
||||||
|
|
||||||
|
const paths = {
|
||||||
scripts: [
|
scripts: [
|
||||||
'./tests/**/*.spec.js',
|
'./tests/**/*.spec.js',
|
||||||
'./lib/**/*.js',
|
'./lib/**/*.js',
|
||||||
@ -32,16 +34,12 @@ var paths = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('sass', function() {
|
gulp.task('sass', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return gulp.src(paths.sass)
|
return gulp.src(paths.sass)
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(gulp.dest('./build/css'));
|
.pipe(gulp.dest('./build/css'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('lint', function() {
|
gulp.task('lint', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return gulp.src(paths.scripts)
|
return gulp.src(paths.scripts)
|
||||||
.pipe(jshint())
|
.pipe(jshint())
|
||||||
.pipe(jshint.reporter(jshintStylish))
|
.pipe(jshint.reporter(jshintStylish))
|
||||||
@ -50,8 +48,6 @@ gulp.task('lint', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('watch', [ 'lint', 'sass' ], function() {
|
gulp.task('watch', [ 'lint', 'sass' ], function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
gulp.watch(paths.scripts, [ 'lint' ]);
|
gulp.watch(paths.scripts, [ 'lint' ]);
|
||||||
gulp.watch(paths.sass, [ 'sass' ]);
|
gulp.watch(paths.sass, [ 'sass' ]);
|
||||||
});
|
});
|
||||||
|
@ -18,11 +18,13 @@
|
|||||||
* @module ResinEtcher
|
* @module ResinEtcher
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var angular = require('angular');
|
var angular = require('angular');
|
||||||
var _ = require('lodash');
|
const _ = require('lodash');
|
||||||
var electron = require('electron');
|
const electron = require('electron');
|
||||||
var shell = electron.remote.require('shell');
|
const shell = electron.remote.require('shell');
|
||||||
var dialog = electron.remote.require('./src/dialog');
|
const dialog = electron.remote.require('./src/dialog');
|
||||||
|
|
||||||
require('angular-ui-bootstrap');
|
require('angular-ui-bootstrap');
|
||||||
require('./browser/modules/selection-state');
|
require('./browser/modules/selection-state');
|
||||||
@ -30,7 +32,7 @@ require('./browser/modules/drive-scanner');
|
|||||||
require('./browser/modules/image-writer');
|
require('./browser/modules/image-writer');
|
||||||
require('./browser/modules/path');
|
require('./browser/modules/path');
|
||||||
|
|
||||||
var app = angular.module('ResinEtcher', [
|
const app = angular.module('ResinEtcher', [
|
||||||
'ui.bootstrap',
|
'ui.bootstrap',
|
||||||
|
|
||||||
// Resin Etcher modules
|
// Resin Etcher modules
|
||||||
@ -43,8 +45,6 @@ var app = angular.module('ResinEtcher', [
|
|||||||
// TrackJS integration
|
// TrackJS integration
|
||||||
// http://docs.trackjs.com/tracker/framework-integrations
|
// http://docs.trackjs.com/tracker/framework-integrations
|
||||||
app.config(function($provide) {
|
app.config(function($provide) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
$provide.decorator('$exceptionHandler', function($delegate, $window) {
|
$provide.decorator('$exceptionHandler', function($delegate, $window) {
|
||||||
return function(exception, cause) {
|
return function(exception, cause) {
|
||||||
$window.trackJs.track(exception);
|
$window.trackJs.track(exception);
|
||||||
@ -55,7 +55,7 @@ app.config(function($provide) {
|
|||||||
$provide.decorator('$log', function($delegate, $window) {
|
$provide.decorator('$log', function($delegate, $window) {
|
||||||
|
|
||||||
// Save the original $log.debug()
|
// Save the original $log.debug()
|
||||||
var debugFn = $delegate.debug;
|
let debugFn = $delegate.debug;
|
||||||
|
|
||||||
$delegate.debug = function(message) {
|
$delegate.debug = function(message) {
|
||||||
message = new Date() + ' ' + message;
|
message = new Date() + ' ' + message;
|
||||||
@ -68,9 +68,7 @@ app.config(function($provide) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.controller('AppController', function($q, $log, DriveScannerService, SelectionStateService, ImageWriterService) {
|
app.controller('AppController', function($q, $log, DriveScannerService, SelectionStateService, ImageWriterService) {
|
||||||
'use strict';
|
let self = this;
|
||||||
|
|
||||||
var self = this;
|
|
||||||
this.selection = SelectionStateService;
|
this.selection = SelectionStateService;
|
||||||
this.writer = ImageWriterService;
|
this.writer = ImageWriterService;
|
||||||
this.scanner = DriveScannerService;
|
this.scanner = DriveScannerService;
|
||||||
@ -86,14 +84,14 @@ app.controller('AppController', function($q, $log, DriveScannerService, Selectio
|
|||||||
// otherwise the drive is selected while the drive step is disabled
|
// otherwise the drive is selected while the drive step is disabled
|
||||||
// which looks very weird.
|
// which looks very weird.
|
||||||
if (drives.length === 1 && self.selection.hasImage()) {
|
if (drives.length === 1 && self.selection.hasImage()) {
|
||||||
var drive = _.first(drives);
|
const drive = _.first(drives);
|
||||||
|
|
||||||
// Do not autoselect the same drive over and over again
|
// Do not autoselect the same drive over and over again
|
||||||
// and fill the logs unnecessary.
|
// and fill the logs unnecessary.
|
||||||
// `angular.equals` is used instead of `_.isEqual` to
|
// `angular.equals` is used instead of `_.isEqual` to
|
||||||
// cope with `$$hashKey`.
|
// cope with `$$hashKey`.
|
||||||
if (!angular.equals(self.selection.getDrive(), drive)) {
|
if (!angular.equals(self.selection.getDrive(), drive)) {
|
||||||
$log.debug('Autoselecting drive: ' + drive.device);
|
$log.debug(`Autoselecting drive: ${drive.device}`);
|
||||||
self.selectDrive(drive);
|
self.selectDrive(drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +115,13 @@ app.controller('AppController', function($q, $log, DriveScannerService, Selectio
|
|||||||
this.selectImage = function() {
|
this.selectImage = function() {
|
||||||
return $q.when(dialog.selectImage()).then(function(image) {
|
return $q.when(dialog.selectImage()).then(function(image) {
|
||||||
self.selection.setImage(image);
|
self.selection.setImage(image);
|
||||||
$log.debug('Image selected: ' + image);
|
$log.debug(`Image selected: ${image}`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectDrive = function(drive) {
|
this.selectDrive = function(drive) {
|
||||||
self.selection.setDrive(drive);
|
self.selection.setDrive(drive);
|
||||||
$log.debug('Drive selected: ' + drive.device);
|
$log.debug(`Drive selected: ${drive.device}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reselectImage = function() {
|
this.reselectImage = function() {
|
||||||
@ -155,7 +153,7 @@ app.controller('AppController', function($q, $log, DriveScannerService, Selectio
|
|||||||
// otherwise Windows throws EPERM
|
// otherwise Windows throws EPERM
|
||||||
self.scanner.stop();
|
self.scanner.stop();
|
||||||
|
|
||||||
$log.debug('Burning ' + image + ' to ' + drive.device);
|
$log.debug(`Burning ${image} to ${drive.device}`);
|
||||||
return self.writer.burn(image, drive).then(function() {
|
return self.writer.burn(image, drive).then(function() {
|
||||||
$log.debug('Done!');
|
$log.debug('Done!');
|
||||||
}).catch(dialog.showError);
|
}).catch(dialog.showError);
|
||||||
|
@ -14,14 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ResinEtcher.drive-scanner
|
* @module ResinEtcher.drive-scanner
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var angular = require('angular');
|
const angular = require('angular');
|
||||||
var _ = require('lodash');
|
const _ = require('lodash');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
var electron = require('electron');
|
const electron = require('electron');
|
||||||
|
|
||||||
if (window.mocha) {
|
if (window.mocha) {
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
@ -33,12 +35,10 @@ if (window.mocha) {
|
|||||||
var dialog = electron.remote.require('./src/dialog');
|
var dialog = electron.remote.require('./src/dialog');
|
||||||
}
|
}
|
||||||
|
|
||||||
var driveScanner = angular.module('ResinEtcher.drive-scanner', []);
|
const driveScanner = angular.module('ResinEtcher.drive-scanner', []);
|
||||||
|
|
||||||
driveScanner.service('DriveScannerRefreshService', function($interval, $timeout) {
|
driveScanner.service('DriveScannerRefreshService', function($interval, $timeout) {
|
||||||
'use strict';
|
let interval = null;
|
||||||
|
|
||||||
var interval = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Run a function every certain milliseconds
|
* @summary Run a function every certain milliseconds
|
||||||
@ -80,9 +80,7 @@ driveScanner.service('DriveScannerRefreshService', function($interval, $timeout)
|
|||||||
});
|
});
|
||||||
|
|
||||||
driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshService) {
|
driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshService) {
|
||||||
'use strict';
|
let self = this;
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary List of available drives
|
* @summary List of available drives
|
||||||
@ -160,14 +158,14 @@ driveScanner.service('DriveScannerService', function($q, DriveScannerRefreshServ
|
|||||||
* @returns {EventEmitter} event emitter instance
|
* @returns {EventEmitter} event emitter instance
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* var emitter = DriveScannerService.start(2000);
|
* const emitter = DriveScannerService.start(2000);
|
||||||
*
|
*
|
||||||
* emitter.on('scan', function(drives) {
|
* emitter.on('scan', function(drives) {
|
||||||
* console.log(drives);
|
* console.log(drives);
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
this.start = function(ms) {
|
this.start = function(ms) {
|
||||||
var emitter = new EventEmitter();
|
let emitter = new EventEmitter();
|
||||||
|
|
||||||
DriveScannerRefreshService.every(function() {
|
DriveScannerRefreshService.every(function() {
|
||||||
return self.scan().then(function(drives) {
|
return self.scan().then(function(drives) {
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ResinEtcher.image-writer
|
* @module ResinEtcher.image-writer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var angular = require('angular');
|
const angular = require('angular');
|
||||||
var electron = require('electron');
|
const electron = require('electron');
|
||||||
|
|
||||||
if (window.mocha) {
|
if (window.mocha) {
|
||||||
var writer = electron.remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer'));
|
var writer = electron.remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer'));
|
||||||
@ -27,13 +29,11 @@ if (window.mocha) {
|
|||||||
var writer = electron.remote.require('./src/writer');
|
var writer = electron.remote.require('./src/writer');
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageWriter = angular.module('ResinEtcher.image-writer', []);
|
const imageWriter = angular.module('ResinEtcher.image-writer', []);
|
||||||
|
|
||||||
imageWriter.service('ImageWriterService', function($q, $timeout, $log) {
|
imageWriter.service('ImageWriterService', function($q, $timeout, $log) {
|
||||||
'use strict';
|
let self = this;
|
||||||
|
let burning = false;
|
||||||
var self = this;
|
|
||||||
var burning = false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @summary Progress state
|
* @summary Progress state
|
||||||
@ -80,7 +80,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout, $log) {
|
|||||||
// Transform bytes to megabytes preserving only two decimal places
|
// Transform bytes to megabytes preserving only two decimal places
|
||||||
self.state.speed = Math.floor(state.speed / 1e+6 * 100) / 100 || 0;
|
self.state.speed = Math.floor(state.speed / 1e+6 * 100) / 100 || 0;
|
||||||
|
|
||||||
$log.debug('Progress: ' + self.state.progress + '% at ' + self.state.speed + ' MB/s');
|
$log.debug(`Progress: ${self.state.progress}% at ${self.state.speed} MB/s`);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -14,17 +14,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ResinEtcher.path
|
* @module ResinEtcher.path
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var angular = require('angular');
|
const angular = require('angular');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var pathModule = angular.module('ResinEtcher.path', []);
|
const pathModule = angular.module('ResinEtcher.path', []);
|
||||||
|
|
||||||
pathModule.filter('basename', function() {
|
pathModule.filter('basename', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Get the basename of a path
|
* @summary Get the basename of a path
|
||||||
|
@ -14,25 +14,25 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ResinEtcher.selection-state
|
* @module ResinEtcher.selection-state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var _ = require('lodash');
|
const _ = require('lodash');
|
||||||
var angular = require('angular');
|
const angular = require('angular');
|
||||||
var selectionState = angular.module('ResinEtcher.selection-state', []);
|
const selectionState = angular.module('ResinEtcher.selection-state', []);
|
||||||
|
|
||||||
selectionState.service('SelectionStateService', function() {
|
selectionState.service('SelectionStateService', function() {
|
||||||
'use strict';
|
let self = this;
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Selection state
|
* @summary Selection state
|
||||||
* @type Object
|
* @type Object
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
var selection = {};
|
let selection = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Set a drive
|
* @summary Set a drive
|
||||||
@ -72,7 +72,7 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
* @returns {Object} drive
|
* @returns {Object} drive
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* var drive = SelectionStateService.getDrive();
|
* const drive = SelectionStateService.getDrive();
|
||||||
*/
|
*/
|
||||||
this.getDrive = function() {
|
this.getDrive = function() {
|
||||||
return selection.drive;
|
return selection.drive;
|
||||||
@ -86,7 +86,7 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
* @returns {String} image
|
* @returns {String} image
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* var image = SelectionStateService.getImage();
|
* const image = SelectionStateService.getImage();
|
||||||
*/
|
*/
|
||||||
this.getImage = function() {
|
this.getImage = function() {
|
||||||
return selection.image;
|
return selection.image;
|
||||||
@ -132,9 +132,7 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
* @example
|
* @example
|
||||||
* SelectionStateService.removeDrive();
|
* SelectionStateService.removeDrive();
|
||||||
*/
|
*/
|
||||||
this.removeDrive = function() {
|
this.removeDrive = _.partial(self.setDrive, undefined);
|
||||||
self.setDrive(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Remove image
|
* @summary Remove image
|
||||||
@ -144,9 +142,7 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
* @example
|
* @example
|
||||||
* SelectionStateService.removeImage();
|
* SelectionStateService.removeImage();
|
||||||
*/
|
*/
|
||||||
this.removeImage = function() {
|
this.removeImage = _.partial(self.setImage, undefined);
|
||||||
self.setImage(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Clear selections
|
* @summary Clear selections
|
||||||
|
@ -19,6 +19,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({ is: "hero-badge" });
|
Polymer({ is: 'hero-badge' });
|
||||||
</script>
|
</script>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
is: "hero-button",
|
is: 'hero-button',
|
||||||
properties: {
|
properties: {
|
||||||
disabled: {
|
disabled: {
|
||||||
type: String
|
type: String
|
||||||
@ -51,7 +51,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ready: function() {
|
ready: function() {
|
||||||
this.querySelector('.btn').className += ' btn-' + this.type;
|
'use strict';
|
||||||
|
|
||||||
|
this.querySelector('.btn').className += ` btn-${this.type}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,6 +15,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({ is: "hero-caption" });
|
Polymer({ is: 'hero-caption' });
|
||||||
</script>
|
</script>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: "hero-icon",
|
is: 'hero-icon',
|
||||||
properties: {
|
properties: {
|
||||||
path: {
|
path: {
|
||||||
type: String
|
type: String
|
||||||
@ -40,9 +40,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ready: function() {
|
ready: function() {
|
||||||
var iconElement = this.querySelector('.icon');
|
'use strict';
|
||||||
var imagePath = path.join(__dirname, this.path);
|
|
||||||
var contents = fs.readFileSync(imagePath, {
|
const iconElement = this.querySelector('.icon');
|
||||||
|
const imagePath = path.join(__dirname, this.path);
|
||||||
|
const contents = fs.readFileSync(imagePath, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
is: "hero-progress-button",
|
is: 'hero-progress-button',
|
||||||
properties: {
|
properties: {
|
||||||
disabled: {
|
disabled: {
|
||||||
type: String
|
type: String
|
||||||
@ -49,10 +49,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setProgress: function(percentage) {
|
setProgress: function(percentage) {
|
||||||
var bar = this.querySelector('.bar');
|
'use strict';
|
||||||
|
|
||||||
|
let bar = this.querySelector('.bar');
|
||||||
bar.style.width = percentage + '%';
|
bar.style.width = percentage + '%';
|
||||||
},
|
},
|
||||||
ready: function() {
|
ready: function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
this.setProgress(this.percentage);
|
this.setProgress(this.percentage);
|
||||||
this.addEventListener('percentage-changed', function(event) {
|
this.addEventListener('percentage-changed', function(event) {
|
||||||
this.setProgress(event.detail.value);
|
this.setProgress(event.detail.value);
|
||||||
|
@ -24,21 +24,23 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
is: "hero-tick",
|
is: 'hero-tick',
|
||||||
properties: {
|
properties: {
|
||||||
type: {
|
type: {
|
||||||
type: String
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ready: function() {
|
ready: function() {
|
||||||
var glyphicon = this.querySelector('.glyphicon');
|
'use strict';
|
||||||
|
|
||||||
|
let glyphicon = this.querySelector('.glyphicon');
|
||||||
|
|
||||||
if (this.type === 'success') {
|
if (this.type === 'success') {
|
||||||
glyphicon.className += ' glyphicon-ok';
|
glyphicon.className += ' glyphicon-ok';
|
||||||
} else if (this.type === 'error') {
|
} else if (this.type === 'error') {
|
||||||
glyphicon.className += ' glyphicon-remove';
|
glyphicon.className += ' glyphicon-remove';
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unknown hero-tick type: ' + this.state);
|
throw new Error(`Unknown hero-tick type: ${this.state}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -14,16 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var _ = require('lodash');
|
'use strict';
|
||||||
var electron = require('electron');
|
|
||||||
var isElevated = require('is-elevated');
|
const _ = require('lodash');
|
||||||
var sudoPrompt = require('sudo-prompt');
|
const electron = require('electron');
|
||||||
var os = require('os');
|
const isElevated = require('is-elevated');
|
||||||
var platform = os.platform();
|
const sudoPrompt = require('sudo-prompt');
|
||||||
|
const os = require('os');
|
||||||
|
const platform = os.platform();
|
||||||
|
|
||||||
exports.require = function(app, callback) {
|
exports.require = function(app, callback) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
isElevated(function(error, elevated) {
|
isElevated(function(error, elevated) {
|
||||||
if (error) {
|
if (error) {
|
||||||
return callback(error);
|
return callback(error);
|
||||||
@ -52,7 +52,7 @@ exports.require = function(app, callback) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
} else if (platform === 'win32') {
|
} else if (platform === 'win32') {
|
||||||
var elevator = require('elevator');
|
const elevator = require('elevator');
|
||||||
|
|
||||||
elevator.execute(process.argv, {}, function(error) {
|
elevator.execute(process.argv, {}, function(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -14,15 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var electron = require('electron');
|
'use strict';
|
||||||
var path = require('path');
|
|
||||||
var elevate = require('./elevate');
|
const electron = require('electron');
|
||||||
var mainWindow = null;
|
const path = require('path');
|
||||||
|
const elevate = require('./elevate');
|
||||||
|
let mainWindow = null;
|
||||||
|
|
||||||
electron.app.on('window-all-closed', electron.app.quit);
|
electron.app.on('window-all-closed', electron.app.quit);
|
||||||
|
|
||||||
electron.app.on('ready', function() {
|
electron.app.on('ready', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// No menu bar
|
// No menu bar
|
||||||
electron.Menu.setApplicationMenu(null);
|
electron.Menu.setApplicationMenu(null);
|
||||||
@ -49,7 +50,7 @@ electron.app.on('ready', function() {
|
|||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.loadURL('file://' + path.join(__dirname, 'index.html'));
|
mainWindow.loadURL(`file://${path.join(__dirname, 'index.html')}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var electron = require('electron');
|
'use strict';
|
||||||
var Bluebird = require('bluebird');
|
|
||||||
var _ = require('lodash');
|
const electron = require('electron');
|
||||||
|
const Bluebird = require('bluebird');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Open an image selection dialog
|
* @summary Open an image selection dialog
|
||||||
@ -35,8 +36,6 @@ var _ = require('lodash');
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.selectImage = function() {
|
exports.selectImage = function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return new Bluebird(function(resolve) {
|
return new Bluebird(function(resolve) {
|
||||||
electron.dialog.showOpenDialog({
|
electron.dialog.showOpenDialog({
|
||||||
properties: [ 'openFile' ],
|
properties: [ 'openFile' ],
|
||||||
@ -49,10 +48,8 @@ exports.selectImage = function() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, function(file) {
|
}, resolve);
|
||||||
return resolve(_.first(file));
|
}).get(0);
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +63,5 @@ exports.selectImage = function() {
|
|||||||
* dialog.showError(new Error('Foo Bar'));
|
* dialog.showError(new Error('Foo Bar'));
|
||||||
*/
|
*/
|
||||||
exports.showError = function(error) {
|
exports.showError = function(error) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
electron.dialog.showErrorBox(error.message, error.stack || '');
|
electron.dialog.showErrorBox(error.message, error.stack || '');
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Bluebird = require('bluebird');
|
'use strict';
|
||||||
var drivelist = Bluebird.promisifyAll(require('drivelist'));
|
|
||||||
|
const Bluebird = require('bluebird');
|
||||||
|
const drivelist = Bluebird.promisifyAll(require('drivelist'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary List all available removable drives
|
* @summary List all available removable drives
|
||||||
@ -33,8 +35,6 @@ var drivelist = Bluebird.promisifyAll(require('drivelist'));
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.listRemovable = function() {
|
exports.listRemovable = function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return drivelist.listAsync().then(function(drives) {
|
return drivelist.listAsync().then(function(drives) {
|
||||||
return drives.filter(function(drive) {
|
return drives.filter(function(drive) {
|
||||||
return !drive.system;
|
return !drive.system;
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var imageWrite = require('resin-image-write');
|
'use strict';
|
||||||
var Bluebird = require('bluebird');
|
|
||||||
var umount = Bluebird.promisifyAll(require('umount'));
|
const imageWrite = require('resin-image-write');
|
||||||
var fs = require('fs');
|
const Bluebird = require('bluebird');
|
||||||
var os = require('os');
|
const umount = Bluebird.promisifyAll(require('umount'));
|
||||||
var isWindows = os.platform() === 'win32';
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
|
const isWindows = os.platform() === 'win32';
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
var removedrive = Bluebird.promisifyAll(require('removedrive'));
|
var removedrive = Bluebird.promisifyAll(require('removedrive'));
|
||||||
@ -38,12 +40,10 @@ if (isWindows) {
|
|||||||
* @returns {ReadableStream} image stream
|
* @returns {ReadableStream} image stream
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* var stream = writer.getImageStream('foo/bar/baz.img');
|
* const stream = writer.getImageStream('foo/bar/baz.img');
|
||||||
*/
|
*/
|
||||||
exports.getImageStream = function(image) {
|
exports.getImageStream = function(image) {
|
||||||
'use strict';
|
let stream = fs.createReadStream(image);
|
||||||
|
|
||||||
var stream = fs.createReadStream(image);
|
|
||||||
stream.length = fs.statSync(image).size;
|
stream.length = fs.statSync(image).size;
|
||||||
return stream;
|
return stream;
|
||||||
};
|
};
|
||||||
@ -73,10 +73,8 @@ exports.getImageStream = function(image) {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.writeImage = function(image, drive, onProgress) {
|
exports.writeImage = function(image, drive, onProgress) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return umount.umountAsync(drive.device).then(function() {
|
return umount.umountAsync(drive.device).then(function() {
|
||||||
var stream = exports.getImageStream(image);
|
let stream = exports.getImageStream(image);
|
||||||
return imageWrite.write(drive.device, stream);
|
return imageWrite.write(drive.device, stream);
|
||||||
}).then(function(writer) {
|
}).then(function(writer) {
|
||||||
return new Bluebird(function(resolve, reject) {
|
return new Bluebird(function(resolve, reject) {
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var angular = require('angular');
|
|
||||||
|
const m = require('mochainon');
|
||||||
|
const angular = require('angular');
|
||||||
require('angular-mocks');
|
require('angular-mocks');
|
||||||
require('../../../lib/browser/modules/drive-scanner');
|
require('../../../lib/browser/modules/drive-scanner');
|
||||||
|
|
||||||
describe('Browser: DriveScanner', function() {
|
describe('Browser: DriveScanner', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
beforeEach(angular.mock.module('ResinEtcher.drive-scanner'));
|
beforeEach(angular.mock.module('ResinEtcher.drive-scanner'));
|
||||||
|
|
||||||
describe('DriveScannerRefreshService', function() {
|
describe('DriveScannerRefreshService', function() {
|
||||||
|
|
||||||
var DriveScannerRefreshService;
|
let DriveScannerRefreshService;
|
||||||
var $interval;
|
let $interval;
|
||||||
var $timeout;
|
let $timeout;
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function(_$interval_, _$timeout_, _DriveScannerRefreshService_) {
|
beforeEach(angular.mock.inject(function(_$interval_, _$timeout_, _DriveScannerRefreshService_) {
|
||||||
$interval = _$interval_;
|
$interval = _$interval_;
|
||||||
@ -23,7 +24,7 @@ describe('Browser: DriveScanner', function() {
|
|||||||
describe('.every()', function() {
|
describe('.every()', function() {
|
||||||
|
|
||||||
it('should call the function right away', function() {
|
it('should call the function right away', function() {
|
||||||
var spy = m.sinon.spy();
|
const spy = m.sinon.spy();
|
||||||
DriveScannerRefreshService.every(spy, 1000);
|
DriveScannerRefreshService.every(spy, 1000);
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
DriveScannerRefreshService.stop();
|
DriveScannerRefreshService.stop();
|
||||||
@ -31,7 +32,7 @@ describe('Browser: DriveScanner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call the function in an interval', function() {
|
it('should call the function in an interval', function() {
|
||||||
var spy = m.sinon.spy();
|
const spy = m.sinon.spy();
|
||||||
DriveScannerRefreshService.every(spy, 100);
|
DriveScannerRefreshService.every(spy, 100);
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
@ -48,10 +49,10 @@ describe('Browser: DriveScanner', function() {
|
|||||||
|
|
||||||
describe('DriveScannerService', function() {
|
describe('DriveScannerService', function() {
|
||||||
|
|
||||||
var $interval;
|
let $interval;
|
||||||
var $timeout;
|
let $timeout;
|
||||||
var $q;
|
let $q;
|
||||||
var DriveScannerService;
|
let DriveScannerService;
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function(_$interval_, _$timeout_, _$q_, _DriveScannerService_) {
|
beforeEach(angular.mock.inject(function(_$interval_, _$timeout_, _$q_, _DriveScannerService_) {
|
||||||
$interval = _$interval_;
|
$interval = _$interval_;
|
||||||
@ -69,7 +70,7 @@ describe('Browser: DriveScanner', function() {
|
|||||||
describe('.hasAvailableDrives()', function() {
|
describe('.hasAvailableDrives()', function() {
|
||||||
|
|
||||||
it('should return false', function() {
|
it('should return false', function() {
|
||||||
var hasDrives = DriveScannerService.hasAvailableDrives();
|
const hasDrives = DriveScannerService.hasAvailableDrives();
|
||||||
m.chai.expect(hasDrives).to.be.false;
|
m.chai.expect(hasDrives).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ describe('Browser: DriveScanner', function() {
|
|||||||
describe('.setDrives()', function() {
|
describe('.setDrives()', function() {
|
||||||
|
|
||||||
it('should be able to set drives', function() {
|
it('should be able to set drives', function() {
|
||||||
var drives = [
|
const drives = [
|
||||||
{
|
{
|
||||||
device: '/dev/sdb',
|
device: '/dev/sdb',
|
||||||
description: 'Foo',
|
description: 'Foo',
|
||||||
@ -122,7 +123,7 @@ describe('Browser: DriveScanner', function() {
|
|||||||
describe('.hasAvailableDrives()', function() {
|
describe('.hasAvailableDrives()', function() {
|
||||||
|
|
||||||
it('should return true', function() {
|
it('should return true', function() {
|
||||||
var hasDrives = DriveScannerService.hasAvailableDrives();
|
const hasDrives = DriveScannerService.hasAvailableDrives();
|
||||||
m.chai.expect(hasDrives).to.be.true;
|
m.chai.expect(hasDrives).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,8 +185,8 @@ describe('Browser: DriveScanner', function() {
|
|||||||
describe('.start()', function() {
|
describe('.start()', function() {
|
||||||
|
|
||||||
it('should emit a `scan` event with the drives', function() {
|
it('should emit a `scan` event with the drives', function() {
|
||||||
var emitter = DriveScannerService.start(2000);
|
const emitter = DriveScannerService.start(2000);
|
||||||
var scanSpy = m.sinon.spy();
|
const scanSpy = m.sinon.spy();
|
||||||
emitter.on('scan', scanSpy);
|
emitter.on('scan', scanSpy);
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
$interval.flush(1000);
|
$interval.flush(1000);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var angular = require('angular');
|
|
||||||
|
const m = require('mochainon');
|
||||||
|
const angular = require('angular');
|
||||||
require('angular-mocks');
|
require('angular-mocks');
|
||||||
require('../../../lib/browser/modules/image-writer');
|
require('../../../lib/browser/modules/image-writer');
|
||||||
|
|
||||||
describe('Browser: ImageWriter', function() {
|
describe('Browser: ImageWriter', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
beforeEach(angular.mock.module('ResinEtcher.image-writer'));
|
beforeEach(angular.mock.module('ResinEtcher.image-writer'));
|
||||||
|
|
||||||
describe('ImageWriterService', function() {
|
describe('ImageWriterService', function() {
|
||||||
|
|
||||||
var $q;
|
let $q;
|
||||||
var $timeout;
|
let $timeout;
|
||||||
var $rootScope;
|
let $rootScope;
|
||||||
var ImageWriterService;
|
let ImageWriterService;
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function(_$q_, _$timeout_, _$rootScope_, _ImageWriterService_) {
|
beforeEach(angular.mock.inject(function(_$q_, _$timeout_, _$rootScope_, _ImageWriterService_) {
|
||||||
$q = _$q_;
|
$q = _$q_;
|
||||||
@ -174,7 +175,7 @@ describe('Browser: ImageWriter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be rejected with the error', function() {
|
it('should be rejected with the error', function() {
|
||||||
var rejection;
|
let rejection;
|
||||||
ImageWriterService.burn('foo.img', '/dev/disk2').catch(function(error) {
|
ImageWriterService.burn('foo.img', '/dev/disk2').catch(function(error) {
|
||||||
rejection = error;
|
rejection = error;
|
||||||
});
|
});
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var angular = require('angular');
|
|
||||||
var os = require('os');
|
const m = require('mochainon');
|
||||||
|
const angular = require('angular');
|
||||||
|
const os = require('os');
|
||||||
require('angular-mocks');
|
require('angular-mocks');
|
||||||
require('../../../lib/browser/modules/path');
|
require('../../../lib/browser/modules/path');
|
||||||
|
|
||||||
describe('Browser: Path', function() {
|
describe('Browser: Path', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
beforeEach(angular.mock.module('ResinEtcher.path'));
|
beforeEach(angular.mock.module('ResinEtcher.path'));
|
||||||
|
|
||||||
describe('BasenameFilter', function() {
|
describe('BasenameFilter', function() {
|
||||||
|
|
||||||
var basenameFilter;
|
let basenameFilter;
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function(_basenameFilter_) {
|
beforeEach(angular.mock.inject(function(_basenameFilter_) {
|
||||||
basenameFilter = _basenameFilter_;
|
basenameFilter = _basenameFilter_;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return the basename', function() {
|
it('should return the basename', function() {
|
||||||
var isWindows = os.platform() === 'win32';
|
const isWindows = os.platform() === 'win32';
|
||||||
var basename;
|
let basename;
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
basename = basenameFilter('C:\\Users\\jviotti\\foo.img');
|
basename = basenameFilter('C:\\Users\\jviotti\\foo.img');
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var angular = require('angular');
|
|
||||||
|
const m = require('mochainon');
|
||||||
|
const angular = require('angular');
|
||||||
require('angular-mocks');
|
require('angular-mocks');
|
||||||
require('../../../lib/browser/modules/selection-state');
|
require('../../../lib/browser/modules/selection-state');
|
||||||
|
|
||||||
describe('Browser: SelectionState', function() {
|
describe('Browser: SelectionState', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
beforeEach(angular.mock.module('ResinEtcher.selection-state'));
|
beforeEach(angular.mock.module('ResinEtcher.selection-state'));
|
||||||
|
|
||||||
describe('SelectionStateService', function() {
|
describe('SelectionStateService', function() {
|
||||||
|
|
||||||
var SelectionStateService;
|
let SelectionStateService;
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function(_SelectionStateService_) {
|
beforeEach(angular.mock.inject(function(_SelectionStateService_) {
|
||||||
SelectionStateService = _SelectionStateService_;
|
SelectionStateService = _SelectionStateService_;
|
||||||
@ -23,22 +24,22 @@ describe('Browser: SelectionState', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('getDrive() should return undefined', function() {
|
it('getDrive() should return undefined', function() {
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.be.undefined;
|
m.chai.expect(drive).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getImage() should return undefined', function() {
|
it('getImage() should return undefined', function() {
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.be.undefined;
|
m.chai.expect(image).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasDrive() should return false', function() {
|
it('hasDrive() should return false', function() {
|
||||||
var hasDrive = SelectionStateService.hasDrive();
|
const hasDrive = SelectionStateService.hasDrive();
|
||||||
m.chai.expect(hasDrive).to.be.false;
|
m.chai.expect(hasDrive).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasImage() should return false', function() {
|
it('hasImage() should return false', function() {
|
||||||
var hasImage = SelectionStateService.hasImage();
|
const hasImage = SelectionStateService.hasImage();
|
||||||
m.chai.expect(hasImage).to.be.false;
|
m.chai.expect(hasImage).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
describe('.getDrive()', function() {
|
describe('.getDrive()', function() {
|
||||||
|
|
||||||
it('should return the drive', function() {
|
it('should return the drive', function() {
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.equal('/dev/disk2');
|
m.chai.expect(drive).to.equal('/dev/disk2');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
describe('.hasDrive()', function() {
|
describe('.hasDrive()', function() {
|
||||||
|
|
||||||
it('should return true', function() {
|
it('should return true', function() {
|
||||||
var hasDrive = SelectionStateService.hasDrive();
|
const hasDrive = SelectionStateService.hasDrive();
|
||||||
m.chai.expect(hasDrive).to.be.true;
|
m.chai.expect(hasDrive).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should override the drive', function() {
|
it('should override the drive', function() {
|
||||||
SelectionStateService.setDrive('/dev/disk5');
|
SelectionStateService.setDrive('/dev/disk5');
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.equal('/dev/disk5');
|
m.chai.expect(drive).to.equal('/dev/disk5');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should clear the drive', function() {
|
it('should clear the drive', function() {
|
||||||
SelectionStateService.removeDrive();
|
SelectionStateService.removeDrive();
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.be.undefined;
|
m.chai.expect(drive).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should be able to set a drive', function() {
|
it('should be able to set a drive', function() {
|
||||||
SelectionStateService.setDrive('/dev/disk5');
|
SelectionStateService.setDrive('/dev/disk5');
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.equal('/dev/disk5');
|
m.chai.expect(drive).to.equal('/dev/disk5');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
describe('.getImage()', function() {
|
describe('.getImage()', function() {
|
||||||
|
|
||||||
it('should return the image', function() {
|
it('should return the image', function() {
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.equal('foo.img');
|
m.chai.expect(image).to.equal('foo.img');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
describe('.hasImage()', function() {
|
describe('.hasImage()', function() {
|
||||||
|
|
||||||
it('should return true', function() {
|
it('should return true', function() {
|
||||||
var hasImage = SelectionStateService.hasImage();
|
const hasImage = SelectionStateService.hasImage();
|
||||||
m.chai.expect(hasImage).to.be.true;
|
m.chai.expect(hasImage).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should override the image', function() {
|
it('should override the image', function() {
|
||||||
SelectionStateService.setImage('bar.img');
|
SelectionStateService.setImage('bar.img');
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.equal('bar.img');
|
m.chai.expect(image).to.equal('bar.img');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should clear the image', function() {
|
it('should clear the image', function() {
|
||||||
SelectionStateService.removeImage();
|
SelectionStateService.removeImage();
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.be.undefined;
|
m.chai.expect(image).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ describe('Browser: SelectionState', function() {
|
|||||||
|
|
||||||
it('should be able to set an image', function() {
|
it('should be able to set an image', function() {
|
||||||
SelectionStateService.setImage('foo.img');
|
SelectionStateService.setImage('foo.img');
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.equal('foo.img');
|
m.chai.expect(image).to.equal('foo.img');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -194,22 +195,22 @@ describe('Browser: SelectionState', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('getDrive() should return undefined', function() {
|
it('getDrive() should return undefined', function() {
|
||||||
var drive = SelectionStateService.getDrive();
|
const drive = SelectionStateService.getDrive();
|
||||||
m.chai.expect(drive).to.be.undefined;
|
m.chai.expect(drive).to.be.undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getImage() should return the image', function() {
|
it('getImage() should return the image', function() {
|
||||||
var image = SelectionStateService.getImage();
|
const image = SelectionStateService.getImage();
|
||||||
m.chai.expect(image).to.equal('foo.img');
|
m.chai.expect(image).to.equal('foo.img');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasDrive() should return false', function() {
|
it('hasDrive() should return false', function() {
|
||||||
var hasDrive = SelectionStateService.hasDrive();
|
const hasDrive = SelectionStateService.hasDrive();
|
||||||
m.chai.expect(hasDrive).to.be.false;
|
m.chai.expect(hasDrive).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasImage() should return true', function() {
|
it('hasImage() should return true', function() {
|
||||||
var hasImage = SelectionStateService.hasImage();
|
const hasImage = SelectionStateService.hasImage();
|
||||||
m.chai.expect(hasImage).to.be.true;
|
m.chai.expect(hasImage).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var electron = require('electron');
|
|
||||||
var dialog = require('../../lib/src/dialog');
|
const m = require('mochainon');
|
||||||
|
const electron = require('electron');
|
||||||
|
const dialog = require('../../lib/src/dialog');
|
||||||
|
|
||||||
describe('Dialog:', function() {
|
describe('Dialog:', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
describe('.selectImage()', function() {
|
describe('.selectImage()', function() {
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ describe('Dialog:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should eventually equal the file', function() {
|
it('should eventually equal the file', function() {
|
||||||
var promise = dialog.selectImage();
|
const promise = dialog.selectImage();
|
||||||
m.chai.expect(promise).to.eventually.equal('foo/bar');
|
m.chai.expect(promise).to.eventually.equal('foo/bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var Bluebird = require('bluebird');
|
|
||||||
var drivelist = require('drivelist');
|
const m = require('mochainon');
|
||||||
var drives = require('../../lib/src/drives');
|
const Bluebird = require('bluebird');
|
||||||
|
const drivelist = require('drivelist');
|
||||||
|
const drives = require('../../lib/src/drives');
|
||||||
|
|
||||||
describe('Drives:', function() {
|
describe('Drives:', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
describe('.listRemovable()', function() {
|
describe('.listRemovable()', function() {
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ describe('Drives:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should eventually equal an empty array', function() {
|
it('should eventually equal an empty array', function() {
|
||||||
var promise = drives.listRemovable();
|
const promise = drives.listRemovable();
|
||||||
m.chai.expect(promise).to.eventually.become([]);
|
m.chai.expect(promise).to.eventually.become([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ describe('Drives:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should eventually equal an empty array', function() {
|
it('should eventually equal an empty array', function() {
|
||||||
var promise = drives.listRemovable();
|
const promise = drives.listRemovable();
|
||||||
m.chai.expect(promise).to.eventually.become([]);
|
m.chai.expect(promise).to.eventually.become([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ describe('Drives:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should eventually become the removable drives', function() {
|
it('should eventually become the removable drives', function() {
|
||||||
var promise = drives.listRemovable();
|
const promise = drives.listRemovable();
|
||||||
m.chai.expect(promise).to.eventually.become([
|
m.chai.expect(promise).to.eventually.become([
|
||||||
{
|
{
|
||||||
device: '/dev/sdb',
|
device: '/dev/sdb',
|
||||||
@ -123,7 +124,7 @@ describe('Drives:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be rejected with the error', function() {
|
it('should be rejected with the error', function() {
|
||||||
var promise = drives.listRemovable();
|
const promise = drives.listRemovable();
|
||||||
m.chai.expect(promise).to.be.rejectedWith('scan error');
|
m.chai.expect(promise).to.be.rejectedWith('scan error');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
var m = require('mochainon');
|
'use strict';
|
||||||
var ReadableStream = require('stream').Readable;
|
|
||||||
var path = require('path');
|
const m = require('mochainon');
|
||||||
var umount = require('umount');
|
const ReadableStream = require('stream').Readable;
|
||||||
var writer = require('../../lib/src/writer');
|
const path = require('path');
|
||||||
|
const umount = require('umount');
|
||||||
|
const writer = require('../../lib/src/writer');
|
||||||
|
|
||||||
describe('Writer:', function() {
|
describe('Writer:', function() {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
describe('.getImageStream()', function() {
|
describe('.getImageStream()', function() {
|
||||||
|
|
||||||
@ -16,12 +17,12 @@ describe('Writer:', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a readable stream', function() {
|
it('should return a readable stream', function() {
|
||||||
var stream = writer.getImageStream(this.image);
|
const stream = writer.getImageStream(this.image);
|
||||||
m.chai.expect(stream).to.be.an.instanceof(ReadableStream);
|
m.chai.expect(stream).to.be.an.instanceof(ReadableStream);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should append a .length property with the correct size', function() {
|
it('should append a .length property with the correct size', function() {
|
||||||
var stream = writer.getImageStream(this.image);
|
const stream = writer.getImageStream(this.image);
|
||||||
m.chai.expect(stream.length).to.equal(2097152);
|
m.chai.expect(stream.length).to.equal(2097152);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user