feature(update) rm

This commit is contained in:
coderaiser 2014-09-17 03:33:49 -04:00
parent 7f0556ec69
commit f3d9a88da1
2 changed files with 2 additions and 59 deletions

View file

@ -5,10 +5,8 @@
DIR_LIB = DIR + 'lib/',
DIR_SERVER = DIR + 'lib/server/',
server = require(DIR_LIB + 'server'),
update = require(DIR_SERVER + 'update'),
config = require(DIR_SERVER + 'config');
server = require(DIR_LIB + 'server'),
config = require(DIR_SERVER + 'config');
module.exports = function(params) {
@ -22,9 +20,6 @@
});
}
if (update)
update.get();
server();
};
})();

View file

@ -1,52 +0,0 @@
/* module update cloud commander */
(function() {
'use strict';
var exec = require('child_process').exec,
fs = require('fs'),
path = require('path'),
Util = require('../util'),
DIR = path.normalize(__dirname + '/../../'),
mainpackage = require(DIR + 'package');
exports.get = function() {
fs.readdir(DIR, function(error, files) {
var cmd = 'git pull --rebase';
if (!error && ~files.indexOf('.git'))
exec(cmd, {cwd : DIR}, pull);
});
};
/**
* function pulls cloud cmd content from repo
* @param error
* @param stdout
* @param stderr
*/
function pull(error, stdout, stderr) {
var msg,
msgError = error || stderr,
name = mainpackage.name,
version = mainpackage.version,
isUpToDate = ' is up to date.';
if (msgError) {
Util.log(msgError);
} else {
stderr = '';
if (Util.isContainStr(stdout, isUpToDate))
msg = isUpToDate;
else
msg = ' updated, restart to use new version.';
msg = name + ' v' + version + msg;
Util.log(msg);
}
}
})();