feature(console) add optional glob for wildcard parsing

This commit is contained in:
coderaiser 2014-08-09 06:19:44 -04:00
parent cfbeb27c0a
commit 9ae54b7f28
3 changed files with 14 additions and 7 deletions

View file

@ -39,6 +39,10 @@
stdout : CLOUDCMD + ' exit \n' +
CLOUDCMD + ' update \n',
};
Util.exec.try(function() {
find = require('glob');
});
/**
* function listen on servers port
@ -338,7 +342,12 @@
if (!isWildCard)
exec(command, {cwd: paramDir}, onExec);
else
find(paramDir, function(error, dir) {
find(paramDir, function(error, dirs) {
var dir;
if (!error)
dir = dirs[0];
paramDir = dir;
exec(command, {cwd: dir}, onExec);
});

View file

@ -14,21 +14,18 @@
throw(Error('Callback is absent!'));
fs.readdir(dir, function(error, names) {
var result;
var result = [];
if (!error)
names.some(function(name) {
names.forEach(function(name) {
var is = name.match(regExp);
if (is)
result = name;
result.push(path.join(dir, name));
return is;
});
if (result)
result = path.join(dir, result);
callback(error, result);
});
};

View file

@ -27,6 +27,7 @@
"dependencies": {
"dropbox": "0.10.x",
"express": "~4.6.1",
"glob": "~4.0.5",
"http-auth": "2.1.x",
"marked": "~0.3.2",
"minify": "~0.7.x",