mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-22 18:56:31 +00:00
We replace the lodash templates with arrow-functions and change the single-argument object into multiple arguments. Fixes #1810 Closes #2006 Change-Type: patch Changelog-Entry: Replace Lodash templates with arrow-functions.
This commit is contained in:
parent
4dc64ee15b
commit
df2ebf93b6
@ -88,10 +88,7 @@ permissions.isElevated().then((elevated) => {
|
|||||||
})
|
})
|
||||||
}).then((results) => {
|
}).then((results) => {
|
||||||
return Bluebird.try(() => {
|
return Bluebird.try(() => {
|
||||||
console.log(messages.info.flashComplete({
|
console.log(messages.info.flashComplete(path.basename(results.imagePath), results.flash.drive))
|
||||||
drive: results.flash.drive,
|
|
||||||
imageBasename: path.basename(results.imagePath)
|
|
||||||
}))
|
|
||||||
|
|
||||||
if (results.flash.checksum.crc32) {
|
if (results.flash.checksum.crc32) {
|
||||||
console.log(`Checksum: ${results.flash.checksum.crc32}`)
|
console.log(`Checksum: ${results.flash.checksum.crc32}`)
|
||||||
|
@ -82,10 +82,7 @@ module.exports = function (
|
|||||||
return WarningModalService.display({
|
return WarningModalService.display({
|
||||||
confirmationLabel: 'Yes, continue',
|
confirmationLabel: 'Yes, continue',
|
||||||
description: [
|
description: [
|
||||||
messages.warning.unrecommendedDriveSize({
|
messages.warning.unrecommendedDriveSize(selectionState.getImage(), drive),
|
||||||
image: selectionState.getImage(),
|
|
||||||
drive
|
|
||||||
}),
|
|
||||||
'Are you sure you want to continue?'
|
'Are you sure you want to continue?'
|
||||||
].join(' ')
|
].join(' ')
|
||||||
})
|
})
|
||||||
|
@ -75,10 +75,7 @@ module.exports = function (
|
|||||||
imageWriter.flash(image.path, drive).then(() => {
|
imageWriter.flash(image.path, drive).then(() => {
|
||||||
if (!flashState.wasLastFlashCancelled()) {
|
if (!flashState.wasLastFlashCancelled()) {
|
||||||
notification.send('Success!', {
|
notification.send('Success!', {
|
||||||
body: messages.info.flashComplete({
|
body: messages.info.flashComplete(path.basename(image.path), drive),
|
||||||
imageBasename: path.basename(image.path),
|
|
||||||
drive
|
|
||||||
}),
|
|
||||||
icon: iconPath
|
icon: iconPath
|
||||||
})
|
})
|
||||||
$state.go('success')
|
$state.go('success')
|
||||||
@ -86,10 +83,7 @@ module.exports = function (
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
notification.send('Oops! Looks like the flash failed.', {
|
notification.send('Oops! Looks like the flash failed.', {
|
||||||
body: messages.error.flashFailure({
|
body: messages.error.flashFailure(path.basename(image.path), drive),
|
||||||
imageBasename: path.basename(image.path),
|
|
||||||
drive
|
|
||||||
}),
|
|
||||||
icon: iconPath
|
icon: iconPath
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -70,9 +70,7 @@ module.exports = function (
|
|||||||
if (!supportedFormats.isSupportedImage(image.path)) {
|
if (!supportedFormats.isSupportedImage(image.path)) {
|
||||||
const invalidImageError = errors.createUserError({
|
const invalidImageError = errors.createUserError({
|
||||||
title: 'Invalid image',
|
title: 'Invalid image',
|
||||||
description: messages.error.invalidImage({
|
description: messages.error.invalidImage(image)
|
||||||
image
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
osDialog.showError(invalidImageError)
|
osDialog.showError(invalidImageError)
|
||||||
@ -138,10 +136,7 @@ module.exports = function (
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const imageError = errors.createUserError({
|
const imageError = errors.createUserError({
|
||||||
title: 'Error opening image',
|
title: 'Error opening image',
|
||||||
description: messages.error.openImage({
|
description: messages.error.openImage(path.basename(imagePath), error.message)
|
||||||
imageBasename: path.basename(imagePath),
|
|
||||||
errorMessage: error.message
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
osDialog.showError(imageError)
|
osDialog.showError(imageError)
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict'
|
/* eslint-disable lodash/prefer-constant */
|
||||||
|
|
||||||
const _ = require('lodash')
|
'use strict'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Application messages
|
* @summary Application messages
|
||||||
@ -32,11 +32,12 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
info: {
|
info: {
|
||||||
|
|
||||||
flashComplete: _.template([
|
flashComplete: (imageBasename, drive) => {
|
||||||
'<%= imageBasename %> was successfully written to',
|
return [
|
||||||
'<%= drive.description %> (<%= drive.raw %>)'
|
`${imageBasename} was successfully written to`,
|
||||||
].join(' '))
|
`${drive.description} (${drive.displayName})`
|
||||||
|
].join(' ')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,28 +47,36 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
warning: {
|
warning: {
|
||||||
|
|
||||||
unrecommendedDriveSize: _.template([
|
unrecommendedDriveSize: (image, drive) => {
|
||||||
'This image recommends a <%= image.recommendedDriveSize %>',
|
return [
|
||||||
'bytes drive, however <%= drive.device %> is only <%= drive.size %> bytes.'
|
`This image recommends a ${image.recommendedDriveSize}`,
|
||||||
].join(' ')),
|
`bytes drive, however ${drive.device} is only ${drive.size} bytes.`
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
exitWhileFlashing: _.template([
|
exitWhileFlashing: () => {
|
||||||
'You are currently flashing a drive.',
|
return [
|
||||||
'Closing Etcher may leave your drive in an unusable state.'
|
'You are currently flashing a drive.',
|
||||||
].join(' ')),
|
'Closing Etcher may leave your drive in an unusable state.'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
looksLikeWindowsImage: _.template([
|
looksLikeWindowsImage: () => {
|
||||||
'It looks like you are trying to burn a Windows image.\n\n',
|
return [
|
||||||
'Unlike other images, Windows images require special processing to be made bootable.',
|
'It looks like you are trying to burn a Windows image.\n\n',
|
||||||
'We suggest you use a tool specially designed for this purpose, such as',
|
'Unlike other images, Windows images require special processing to be made bootable.',
|
||||||
'<a href="https://rufus.akeo.ie">Rufus</a> (Windows) or Boot Camp Assistant (macOS).'
|
'We suggest you use a tool specially designed for this purpose, such as',
|
||||||
].join(' ')),
|
'<a href="https://rufus.akeo.ie">Rufus</a> (Windows) or Boot Camp Assistant (macOS).'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
missingPartitionTable: _.template([
|
missingPartitionTable: () => {
|
||||||
'It looks like this is not a bootable image.\n\n',
|
return [
|
||||||
'The image does not appear to contain a partition table,',
|
'It looks like this is not a bootable image.\n\n',
|
||||||
'and might not be recognized or bootable by your device.'
|
'The image does not appear to contain a partition table,',
|
||||||
].join(' '))
|
'and might not be recognized or bootable by your device.'
|
||||||
|
].join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -78,49 +87,69 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
error: {
|
error: {
|
||||||
|
|
||||||
notEnoughSpaceInDrive: _.template([
|
notEnoughSpaceInDrive: () => {
|
||||||
'Not enough space on the drive.',
|
return [
|
||||||
'Please insert larger one and try again.'
|
'Not enough space on the drive.',
|
||||||
].join(' ')),
|
'Please insert larger one and try again.'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
genericFlashError: _.template('Oops, seems something went wrong.'),
|
genericFlashError: () => {
|
||||||
|
return 'Oops, seems something went wrong.'
|
||||||
|
},
|
||||||
|
|
||||||
validation: _.template([
|
validation: () => {
|
||||||
'The write has been completed successfully but Etcher detected potential',
|
return [
|
||||||
'corruption issues when reading the image back from the drive.',
|
'The write has been completed successfully but Etcher detected potential',
|
||||||
'\n\nPlease consider writing the image to a different drive.'
|
'corruption issues when reading the image back from the drive.',
|
||||||
].join(' ')),
|
'\n\nPlease consider writing the image to a different drive.'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
invalidImage: _.template('<%= image.path %> is not a supported image type.'),
|
invalidImage: (image) => {
|
||||||
|
return `${image.path} is not a supported image type.`
|
||||||
|
},
|
||||||
|
|
||||||
openImage: _.template([
|
openImage: (imageBasename, errorMessage) => {
|
||||||
'Something went wrong while opening <%= imageBasename %>\n\n',
|
return [
|
||||||
'Error: <%= errorMessage %>'
|
`Something went wrong while opening ${imageBasename}\n\n`,
|
||||||
].join('')),
|
`Error: ${errorMessage}`
|
||||||
|
].join('')
|
||||||
|
},
|
||||||
|
|
||||||
elevationRequired: _.template('This should should be run with root/administrator permissions.'),
|
elevationRequired: () => {
|
||||||
|
return 'This should should be run with root/administrator permissions.'
|
||||||
|
},
|
||||||
|
|
||||||
flashFailure: _.template([
|
flashFailure: (imageBasename, drive) => {
|
||||||
'Something went wrong while writing <%= imageBasename %>',
|
return [
|
||||||
'to <%= drive.description %> (<%= drive.raw %>)'
|
`Something went wrong while writing ${imageBasename}`,
|
||||||
].join(' ')),
|
`to ${drive.description} (${drive.displayName})`
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
driveUnplugged: _.template([
|
driveUnplugged: () => {
|
||||||
'Looks like Etcher lost access to the drive.',
|
return [
|
||||||
'Did it get unplugged accidentally?',
|
'Looks like Etcher lost access to the drive.',
|
||||||
'\n\nSometimes this error is caused by faulty readers that don\'t provide stable access to the drive.'
|
'Did it get unplugged accidentally?',
|
||||||
].join(' ')),
|
'\n\nSometimes this error is caused by faulty readers that don\'t provide stable access to the drive.'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
inputOutput: _.template([
|
inputOutput: () => {
|
||||||
'Looks like Etcher is not able to write to this location of the drive.',
|
return [
|
||||||
'This error is usually caused by a faulty drive, reader, or port.',
|
'Looks like Etcher is not able to write to this location of the drive.',
|
||||||
'\n\nPlease try again with another drive, reader, or port.'
|
'This error is usually caused by a faulty drive, reader, or port.',
|
||||||
].join(' ')),
|
'\n\nPlease try again with another drive, reader, or port.'
|
||||||
|
].join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
childWriterDied: _.template([
|
childWriterDied: () => {
|
||||||
'The writer process ended unexpectedly.',
|
return [
|
||||||
'Please try again, and contact the Etcher team if the problem persists.'
|
'The writer process ended unexpectedly.',
|
||||||
].join(' '))
|
'Please try again, and contact the Etcher team if the problem persists.'
|
||||||
|
].join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user