From 6310fc7fd17868579f51f981ed46c8704e05ad80 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 11 Apr 2015 03:56:19 -0400 Subject: [PATCH] feature(cloudcmd) root: add directory check --- bin/cloudcmd.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index a70dc990..1efeeaf7 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -143,17 +143,23 @@ } function root(dir) { - var current; + var current, + fs = require('fs'); if (!dir) { - current = config('root'); + current = config('root') || '/'; } else { current = dir; config('root', dir); } - if (current && current !== '/') - console.log('root:', dir); + fs.stat(current, function(error) { + if (error) + exit('cloudcmd --root: %s', error.message); + else if (current !== '/') + console.log('root:', dir); + }); + } function repl() {