From b0ffeb1d436188909e9938388fb6cae02473d8c1 Mon Sep 17 00:00:00 2001 From: Santi Date: Tue, 16 May 2017 14:04:09 +0700 Subject: [PATCH] Update the code to support the following cases. - Support the case that there is Drive A: on the machine (no free). - Throw the error when it happens. - Continue the next drive in the case that user specify the second drive instead of return immediately --- lib/disk.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/disk.js b/lib/disk.js index fc5d52e..10f6179 100644 --- a/lib/disk.js +++ b/lib/disk.js @@ -7,8 +7,8 @@ switch(process.env.platform) { module.exports = function(statEmitter, options) { let df = "df -Pkl | grep -v Capacity | awk '{ print $1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7}'"; exec(df, {stdio:['inherit','pipe','pipe']}, function(err, output, code) { - if(err) return; - + if(err) throw err; + let drives = output.split('\n'); drives.forEach(function(drive) { let drivedetails = drive.split(' '); @@ -42,17 +42,17 @@ switch(process.env.platform) { module.exports = function(statEmitter, options) { let wmic = 'wmic LOGICALDISK GET Name, Size, FreeSpace /value | findstr "FreeSpace Name Size"'; exec(wmic, function(err, output, code) { - if(err) return; + if(err) throw err; let segments = output.split('\n'); for(let i=0; i