mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-24 03:36:36 +00:00
Implement validation support in Etcher CLI (#361)
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
86cbff940c
commit
8bdc089de4
@ -41,6 +41,7 @@ module.exports = yargs
|
||||
|
||||
// Examples
|
||||
.example('$0 raspberry-pi.img')
|
||||
.example('$0 --no-check raspberry-pi.img')
|
||||
.example('$0 -d /dev/disk2 ubuntu.iso')
|
||||
.example('$0 -d /dev/disk2 -y rpi.img')
|
||||
|
||||
@ -87,6 +88,12 @@ module.exports = yargs
|
||||
string: true,
|
||||
alias: 'd'
|
||||
},
|
||||
check: {
|
||||
describe: 'validate write',
|
||||
boolean: true,
|
||||
alias: 'c',
|
||||
default: true
|
||||
},
|
||||
robot: {
|
||||
describe: 'parse-able output without interactivity',
|
||||
boolean: true,
|
||||
|
@ -49,13 +49,16 @@ form.run([
|
||||
throw new Error('Aborted');
|
||||
}
|
||||
|
||||
const progressBar = new visuals.Progress('Burning');
|
||||
const progressBars = {
|
||||
write: new visuals.Progress('Flashing'),
|
||||
check: new visuals.Progress('Validating')
|
||||
};
|
||||
|
||||
return writer.writeImage(options._[0], {
|
||||
device: answers.drive
|
||||
}, {
|
||||
unmountOnSuccess: false,
|
||||
validateWriteOnSuccess: false
|
||||
validateWriteOnSuccess: options.check
|
||||
}, function(state) {
|
||||
|
||||
if (options.robot) {
|
||||
@ -66,16 +69,20 @@ form.run([
|
||||
Math.floor(state.speed)
|
||||
].join(' '));
|
||||
} else {
|
||||
progressBar.update(state);
|
||||
progressBars[state.type].update(state);
|
||||
}
|
||||
|
||||
});
|
||||
}).then(function() {
|
||||
}).then(function(success) {
|
||||
|
||||
if (options.robot) {
|
||||
console.log('done');
|
||||
} else {
|
||||
return console.log(`done ${success}`);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
console.log('Your flash is complete!');
|
||||
} else {
|
||||
console.error('Validation failed!');
|
||||
}
|
||||
|
||||
}).catch(function(error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user