mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-25 12:16:37 +00:00
Convert drive-scanner.js to typescript
Change-type: patch
This commit is contained in:
parent
a5825373e1
commit
0377faadd6
@ -36,7 +36,8 @@ const windowProgress = require('./os/window-progress')
|
|||||||
// eslint-disable-next-line node/no-missing-require
|
// eslint-disable-next-line node/no-missing-require
|
||||||
const analytics = require('./modules/analytics')
|
const analytics = require('./modules/analytics')
|
||||||
const availableDrives = require('./models/available-drives')
|
const availableDrives = require('./models/available-drives')
|
||||||
const driveScanner = require('./modules/drive-scanner')
|
// eslint-disable-next-line node/no-missing-require
|
||||||
|
const { scanner: driveScanner } = require('./modules/drive-scanner')
|
||||||
const osDialog = require('./os/dialog')
|
const osDialog = require('./os/dialog')
|
||||||
// eslint-disable-next-line node/no-missing-require
|
// eslint-disable-next-line node/no-missing-require
|
||||||
const exceptionReporter = require('./modules/exception-reporter')
|
const exceptionReporter = require('./modules/exception-reporter')
|
||||||
|
@ -20,7 +20,8 @@ const Bluebird = require('bluebird')
|
|||||||
const fs = Bluebird.promisifyAll(require('fs'))
|
const fs = Bluebird.promisifyAll(require('fs'))
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const driveScanner = require('../modules/drive-scanner')
|
// eslint-disable-next-line node/no-missing-require
|
||||||
|
const { scanner: driveScanner } = require('../modules/drive-scanner')
|
||||||
|
|
||||||
/* eslint-disable lodash/prefer-lodash-method */
|
/* eslint-disable lodash/prefer-lodash-method */
|
||||||
/* eslint-disable no-undefined */
|
/* eslint-disable no-undefined */
|
||||||
|
@ -14,41 +14,33 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict'
|
import * as sdk from 'etcher-sdk';
|
||||||
|
import { geteuid, platform } from 'process';
|
||||||
|
|
||||||
const sdk = require('etcher-sdk')
|
import * as settings from '../models/settings';
|
||||||
const process = require('process')
|
|
||||||
|
|
||||||
const settings = require('../models/settings')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary returns true if system drives should be shown
|
* @summary returns true if system drives should be shown
|
||||||
* @function
|
|
||||||
*
|
|
||||||
* @returns {Boolean}
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* const shouldInclude = includeSystemDrives()
|
|
||||||
*/
|
*/
|
||||||
const includeSystemDrives = () => {
|
function includeSystemDrives() {
|
||||||
return settings.get('unsafeMode') && !settings.get('disableUnsafeMode')
|
return settings.get('unsafeMode') && !settings.get('disableUnsafeMode');
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapters = [
|
const adapters: sdk.scanner.adapters.Adapter[] = [
|
||||||
new sdk.scanner.adapters.BlockDeviceAdapter(includeSystemDrives)
|
new sdk.scanner.adapters.BlockDeviceAdapter(includeSystemDrives),
|
||||||
]
|
];
|
||||||
|
|
||||||
// Can't use permissions.isElevated() here as it returns a promise and we need to set
|
// Can't use permissions.isElevated() here as it returns a promise and we need to set
|
||||||
// module.exports = scanner right now.
|
// module.exports = scanner right now.
|
||||||
// eslint-disable-next-line no-magic-numbers
|
if (platform !== 'linux' || geteuid() === 0) {
|
||||||
if ((process.platform !== 'linux') || (process.geteuid() === 0)) {
|
adapters.push(new sdk.scanner.adapters.UsbbootDeviceAdapter());
|
||||||
adapters.push(new sdk.scanner.adapters.UsbbootDeviceAdapter())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (
|
||||||
adapters.push(new sdk.scanner.adapters.DriverlessDeviceAdapter())
|
platform === 'win32' &&
|
||||||
|
sdk.scanner.adapters.DriverlessDeviceAdapter !== undefined
|
||||||
|
) {
|
||||||
|
adapters.push(new sdk.scanner.adapters.DriverlessDeviceAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
const scanner = new sdk.scanner.Scanner(adapters)
|
export const scanner = new sdk.scanner.Scanner(adapters);
|
||||||
|
|
||||||
module.exports = scanner
|
|
@ -28,7 +28,7 @@ import * as flashState from '../../models/flash-state';
|
|||||||
import * as selection from '../../models/selection-state';
|
import * as selection from '../../models/selection-state';
|
||||||
import * as store from '../../models/store';
|
import * as store from '../../models/store';
|
||||||
import * as analytics from '../../modules/analytics';
|
import * as analytics from '../../modules/analytics';
|
||||||
import * as driveScanner from '../../modules/drive-scanner';
|
import { scanner as driveScanner } from '../../modules/drive-scanner';
|
||||||
import * as imageWriter from '../../modules/image-writer';
|
import * as imageWriter from '../../modules/image-writer';
|
||||||
import * as progressStatus from '../../modules/progress-status';
|
import * as progressStatus from '../../modules/progress-status';
|
||||||
import * as notification from '../../os/notification';
|
import * as notification from '../../os/notification';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user