From 5e145d496f446ce842460829bd7cd9891658c1e2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 12 Jul 2013 15:04:18 +0000 Subject: [PATCH] feature(update) exec -> exec(cwd) modified: lib/server/update.js modified: ChangeLog --- ChangeLog | 2 ++ lib/server/update.js | 38 ++++++++++++++------------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 774240c5..2a67e93e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -112,6 +112,8 @@ getJSONfromFileTable. * feauture(client) add unload event +* feature(update) exec -> exec(cwd) + 2012.04.22, v0.2.0 diff --git a/lib/server/update.js b/lib/server/update.js index c69af6a4..379a19c9 100644 --- a/lib/server/update.js +++ b/lib/server/update.js @@ -13,20 +13,13 @@ '# http://coderaiser.github.com/cloudcmd' + '\n'); var main = global.cloudcmd.main, - mainpackage = main.mainpackage, + mainpackage = main.mainpackage || {}, exec = main.child_process.exec, Util = main.util, DIR = main.DIR; exports.get = function(){ - var lPull = function(){ - exec('git pull', pull); - }; - - if( process.cwd === DIR ) - lPull(); - else - exec('cd ' + DIR, lPull); + exec('git pull', {cwd : DIR}, pull); }; /** @@ -36,30 +29,27 @@ * @param pStderr */ function pull(pError, pStdout, pStderr){ - var lExec, lStdout = 'Cloud Commander '; + var lExec, lStdout, + lName = mainpackage.name, + lVersion = mainpackage.version; if(!pError) { pStderr = ''; if (pStdout !== 'Already up-to-date.\n') - lStdout += 'updated. Restart to use new version.'; + lStdout = ' updated, restart to use new version.'; else - lStdout += 'is up to date.'; + lStdout = ' is up to date.'; - Util.log(DIR); + lStdout = lName + ' v' + lVersion + lStdout; - if (mainpackage) - lStdout = 'Version ' + mainpackage.version + '\n' + lStdout; - - lExec = { - stdout : pStdout, - stderr : pStderr || pError - }; - } else + lExec = pStderr || pError || lStdout; + Util.log(lExec); + } else { lExec = ['install git to get auto updates (works for cloned version)', - 'or start cloudcmd from root of Cloud Commander dir', 'git clone http://github.com/coderaiser/cloudcmd']; - - Util.logArray(lExec); + + Util.logArray(lExec); + } } })();