mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(console) add optional glob for wildcard parsing
This commit is contained in:
parent
cfbeb27c0a
commit
9ae54b7f28
3 changed files with 14 additions and 7 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue