From c18921a5c223b7f7e7436347841014d8bba77d37 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 27 Oct 2016 11:36:27 +0300 Subject: [PATCH] feature(validate) mv console.log out --- bin/cloudcmd.js | 7 +++++++ lib/server/validate.js | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 5673c776..65d97e48 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -101,6 +101,8 @@ if (args.version) { if (args.password) config('password', getPassword(args.password)); + validateRoot(options.root); + if (!args.save) start(options); else @@ -109,6 +111,11 @@ if (args.version) { }); } +function validateRoot(root) { + var validate = require('../lib/server/validate'); + validate.root(root, console.log); +} + function getPassword(password) { var criton = require('criton'); diff --git a/lib/server/validate.js b/lib/server/validate.js index a007af2a..dc8a2096 100644 --- a/lib/server/validate.js +++ b/lib/server/validate.js @@ -5,7 +5,7 @@ var exit = require('./exit'); module.exports.root = root; module.exports.editor = editor; -function root(dir) { +function root(dir, fn) { var fs; if (dir !== '/') { @@ -13,8 +13,8 @@ function root(dir) { fs.stat(dir, function(error) { if (error) exit('cloudcmd --root: %s', error.message); - else - console.log('root:', dir); + else if (typeof fn === 'function') + fn('root:', dir); }); } }