fix(CLI): throw error if image is inaccessible (#1281)

Consider the following scenario:

- The user selects an image from an external drive
- The user selects a drive
- The user unmounts/ejects the external drive
- The user clicks flash

The application state will contain an image path that is no longer
accessible, causing an ENOENT error when spawning the CLI process.

Change-Type: patch
Changelog-Entry: Display a user error if the image is no longer accessible when the writer starts.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
Juan Cruz Viotti 2017-04-11 00:59:08 -04:00 committed by GitHub
parent 6deec4bbb5
commit 68f87435de

View File

@ -107,7 +107,14 @@ module.exports = yargs
// Assert that image exists
.check((argv) => {
fs.accessSync(argv._[IMAGE_PATH_ARGV_INDEX]);
const imagePath = argv._[IMAGE_PATH_ARGV_INDEX];
try {
fs.accessSync(imagePath);
} catch (error) {
throw errors.createUserError('Unable to access file', `The image ${imagePath} is not accessible`);
}
return true;
})