feature(util) bind -> exec.with

This commit is contained in:
coderaiser 2014-05-23 07:55:24 -04:00
parent ec9a78a27a
commit 6b58016616
16 changed files with 61 additions and 60 deletions

View file

@ -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');

View file

@ -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) {

View file

@ -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);
});
}

View file

@ -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
});
});

View file

@ -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)