mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(util) bind -> exec.with
This commit is contained in:
parent
ec9a78a27a
commit
6b58016616
16 changed files with 61 additions and 60 deletions
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
Clients[ConNum] = true;
|
||||
|
||||
onMessage = Util.bind(getOnMessage, ConNum, callback);
|
||||
onMessage = Util.exec.with(getOnMessage, ConNum, callback);
|
||||
onDisconnect = function(conNum) {
|
||||
Clients[conNum] =
|
||||
ClientFuncs[conNum] = null;
|
||||
|
|
@ -152,7 +152,7 @@
|
|||
}
|
||||
|
||||
if (!ClientFuncs[connNum])
|
||||
ClientFuncs[connNum] = Util.bind(setExec, function(json, error, stderr) {
|
||||
ClientFuncs[connNum] = Util.exec.with(setExec, function(json, error, stderr) {
|
||||
log(connNum, error, 'error');
|
||||
log(connNum, stderr, 'stderror');
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
fileCounter = 1;
|
||||
|
||||
function getDirInfo(dir) {
|
||||
stat(dir, Util.bind(getStat, dir));
|
||||
stat(dir, Util.exec.with(getStat, dir));
|
||||
}
|
||||
|
||||
function getStat(dir, error, stat) {
|
||||
|
|
|
|||
|
|
@ -11,16 +11,17 @@
|
|||
|
||||
function join(before, req, res, callback) {
|
||||
var names,
|
||||
readFunc = Util.bind(readPipe, req, res),
|
||||
exec = Util.exec,
|
||||
readFunc = exec.with(readPipe, req, res),
|
||||
path = main.getPathName(req),
|
||||
isJoin = CloudFunc.isJoinURL(path);
|
||||
|
||||
if (!isJoin)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
if (!isJoin) {
|
||||
exec(callback);
|
||||
} else {
|
||||
names = CloudFunc.getJoinArray(path);
|
||||
|
||||
Util.exec.if(!before, readFunc, function(callback) {
|
||||
exec.if(!before, readFunc, function(callback) {
|
||||
before(names, callback);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,25 +29,26 @@
|
|||
INDEX : HTMLDIR + 'index.html',
|
||||
|
||||
optimize: function(name, params) {
|
||||
var minifyName, isChanged, isExist;
|
||||
var minifyName, isChanged, isExist,
|
||||
exec = Util.exec;
|
||||
|
||||
if (!Minify) {
|
||||
Util.log(COULD_NOT_MINIFY);
|
||||
Util.exec(params.callback);
|
||||
exec(params.callback);
|
||||
} else {
|
||||
minifyName = Minify.getName(name),
|
||||
|
||||
isChanged = Util.bind(IsChanged.isFileChanged, name),
|
||||
isExist = Util.bind(fs.exists, minifyName);
|
||||
isChanged = exec.with(IsChanged.isFileChanged, name),
|
||||
isExist = exec.with(fs.exists, minifyName);
|
||||
|
||||
if (!this.MinFolder)
|
||||
this.MinFolder = Minify.MinFolder;
|
||||
|
||||
Util.exec.parallel([isChanged, isExist], function(changed, exists) {
|
||||
exec.parallel([isChanged, isExist], function(changed, exists) {
|
||||
if (changed || !exists)
|
||||
Minify.optimize(name, params);
|
||||
else
|
||||
Util.exec(params.callback, null, {
|
||||
exec(params.callback, null, {
|
||||
name: minifyName
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@
|
|||
WIN32 : 866
|
||||
},
|
||||
|
||||
exec = main.child_process.exec,
|
||||
processExec = main.child_process.exec,
|
||||
Util = main.util;
|
||||
|
||||
exports.getVolumes = function(callback) {
|
||||
var chcp = 'chcp ' + Charset.UNICODE,
|
||||
getVolumes = 'wmic logicaldisk get name';
|
||||
|
||||
exec(chcp + ' && ' + getVolumes, Util.bind(processOuput, callback));
|
||||
processExec(chcp + ' && ' + getVolumes, Util.exec.with(processOuput, callback));
|
||||
};
|
||||
|
||||
function processOuput(callback, error, stdout, stderr) {
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
if (!error)
|
||||
error = stderr;
|
||||
|
||||
exec('chcp ' + Charset.WIN32);
|
||||
processExec('chcp ' + Charset.WIN32);
|
||||
|
||||
if(!error) {
|
||||
volumes = Util.rmStr(stdout, removeStr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue