Prevent writing accidentally to system drives

This commit is contained in:
Juan Cruz Viotti 2015-02-25 11:12:58 -04:00
parent 7c53b35cbd
commit 9c98adb712
3 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,5 @@
_ = require('lodash')
async = require('async')
visuals = require('resin-cli-visuals') visuals = require('resin-cli-visuals')
drivelist = require('drivelist') drivelist = require('drivelist')
@ -15,10 +17,15 @@ exports.list =
drivelist.list (error, drives) -> drivelist.list (error, drives) ->
return done(error) if error? return done(error) if error?
console.log visuals.widgets.table.horizontal drives, [ async.reject drives, drivelist.isSystem, (removableDrives) ->
'device'
'description'
'size'
]
return done() if _.isEmpty(removableDrives)
return done(new Error('No removable devices available'))
console.log visuals.widgets.table.horizontal removableDrives, [
'device'
'description'
'size'
]
return done()

View File

@ -109,7 +109,15 @@ exports.install =
(callback) -> (callback) ->
return callback(null, params.device) if params.device? return callback(null, params.device) if params.device?
visuals.patterns.selectDrive(callback)
# TODO: See if we can reuse the drives action somehow here
visuals.patterns.selectDrive (error, device) ->
return callback(error) if error?
if not device?
return callback(new Error('No removable devices available'))
return callback(null, device)
(device, callback) -> (device, callback) ->
params.device = device params.device = device

View File

@ -52,7 +52,7 @@
"coffee-script": "~1.8.0", "coffee-script": "~1.8.0",
"conf.js": "^0.1.1", "conf.js": "^0.1.1",
"diskio": "^1.0.0", "diskio": "^1.0.0",
"drivelist": "^1.1.1", "drivelist": "^1.2.0",
"git-cli": "~0.8.2", "git-cli": "~0.8.2",
"lodash": "~2.4.1", "lodash": "~2.4.1",
"lodash-contrib": "~241.4.14", "lodash-contrib": "~241.4.14",