mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(console) change directory to ~ + wildcard
This commit is contained in:
parent
f8cad8f5f4
commit
cfbeb27c0a
1 changed files with 10 additions and 14 deletions
|
|
@ -38,13 +38,7 @@
|
|||
HELP = {
|
||||
stdout : CLOUDCMD + ' exit \n' +
|
||||
CLOUDCMD + ' update \n',
|
||||
},
|
||||
|
||||
glob = function(callback) {callback(null, [])};
|
||||
|
||||
Util.exec.try(function() {
|
||||
glob = require('glob');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* function listen on servers port
|
||||
|
|
@ -284,13 +278,13 @@
|
|||
|
||||
function onCD(command, currDir, callback) {
|
||||
var CD = 'cd ',
|
||||
HOME = process.env.HOME,
|
||||
|
||||
isChangeVolume = win.isChangeVolume(command),
|
||||
isVolume = win.isVolume(command),
|
||||
paramDir = Util.rmStrOnce(command, [CD, 'cd']),
|
||||
|
||||
regStrEnd = getRegStrEnd(),
|
||||
regStrHome = '^~$|^~',
|
||||
regExpHome = new RegExp(regStrHome + regStrEnd),
|
||||
regExpHome = new RegExp('^~'),
|
||||
|
||||
isWildCard = Util.isContainStr(paramDir, ['*', '?']),
|
||||
isHome = paramDir.match(regExpHome) && !WIN,
|
||||
|
|
@ -314,15 +308,17 @@
|
|||
};
|
||||
|
||||
if (isHome) {
|
||||
paramDir = process.env.HOME;
|
||||
command = command.replace('~', paramDir);
|
||||
command = command.replace('~', HOME);
|
||||
paramDir = paramDir.replace('~', HOME);
|
||||
}
|
||||
|
||||
if (!paramDir && !WIN)
|
||||
paramDir = '.';
|
||||
|
||||
if (!isHome && !isChangeVolume || isVolume) {
|
||||
if (!isChangeVolume || isVolume) {
|
||||
paramDir = getFirstWord(paramDir);
|
||||
paramDir = path.normalize(paramDir);
|
||||
|
||||
command = Util.rmStrOnce(command, [
|
||||
CD,
|
||||
paramDir,
|
||||
|
|
@ -330,7 +326,7 @@
|
|||
'"' + paramDir + '"',
|
||||
]);
|
||||
|
||||
if (paramDir !== '/')
|
||||
if (!isHome && paramDir !== '/')
|
||||
paramDir = path.join(currDir, paramDir);
|
||||
|
||||
if (isWildCard)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue