Last active
August 29, 2015 14:03
-
-
Save tarzak/f288e19f4b44abc3a7fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* module update cloud commander */ | |
(function(){ | |
'use strict'; | |
if(!global.cloudcmd) | |
return console.log( | |
'# update.js' + '\n' + | |
'# -----------' + '\n' + | |
'# Module is part of Cloud Commander,' + '\n' + | |
'# used for work update thru git.' + '\n' + | |
'# If you wont to see at work install git' + '\n' + | |
'# http://cloudcmd.io' + '\n'); | |
var main = global.cloudcmd.main, | |
mainpackage = main.mainpackage || {}, | |
exec = main.child_process.exec, | |
Util = main.util, | |
DIR = main.DIR; | |
/* Tarzak's code starts */ | |
var path = '.'; | |
exports.get = function() { | |
fs.readdir(path, function(err, list) { | |
if (!err) | |
if (list.indexOf('.git') >= 0) | |
exec('git pull --rebase', {cwd : DIR}, pull); | |
}); | |
}; | |
/* Tarzak's code ends */ | |
/** | |
* function pulls cloud cmd content from repo | |
* @param pError | |
* @param pStdout | |
* @param pStderr | |
*/ | |
function pull(pError, pStdout, pStderr){ | |
var lExec, lMsg, | |
lError = pError || pStderr, | |
lName = mainpackage.name, | |
lVersion = mainpackage.version, | |
lIsUpToDate = ' is up to date.'; | |
if(!pError) { | |
pStderr = ''; | |
if (Util.isContainStr(pStdout, lIsUpToDate)) | |
lMsg = lIsUpToDate; | |
else | |
lMsg = ' updated, restart to use new version.'; | |
lMsg = lName + ' v' + lVersion + lMsg; | |
lExec = pStderr || pError || lMsg; | |
Util.log(lExec); | |
} else | |
Util.log(lError); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment