feature(console) change directory and do something after ";, &&, ||"

This commit is contained in:
coderaiser 2014-07-25 10:52:28 -04:00
parent 7ffef6df72
commit 7cf9fad27e

View file

@ -281,8 +281,9 @@
isVolume = win.isVolume(command),
paramDir = Util.rmStrOnce(command, [CD, 'cd']),
regExpHome = /^~$|^~\s/,
isRoot = paramDir === '/',
regStrEnd = getRegStrEnd(),
regStrHome = '^~$|^~',
regExpHome = new RegExp(regStrHome + regStrEnd),
isHome = paramDir.match(regExpHome) && !WIN;
if (isHome) {
@ -293,17 +294,19 @@
if (!paramDir && !WIN)
paramDir = '.';
if (!isHome && !isRoot && !isChangeVolume || isVolume) {
if (!isHome && !isChangeVolume || isVolume) {
paramDir = getFirstWord(paramDir);
command = Util.rmStrOnce(command, [
CD,
paramDir,
'\'' + paramDir + '\'',
'"' + paramDir + '"',
]);
paramDir = path.join(currDir, paramDir);
if (paramDir !== '/')
paramDir = path.join(currDir, paramDir);
command = CD + '"' + paramDir + '" ' + command;
command = CD + '"' + paramDir + '" ' + command;
}
exec(command, {cwd: paramDir}, function (error, stdout, stderr) {
@ -327,8 +330,11 @@
function getFirstWord(str) {
var word, result,
regExp = /^(.*?)\s/,
regExpQuotes = /^"(.*)"\s?/,
regStrEnd = getRegStrEnd(),
regStr = '^(.*?)',
regStrQuotes = '^"(.*)"',
regExp = new RegExp(regStr + regStrEnd),
regExpQuotes = new RegExp(regStrQuotes + regStrEnd + '?'),
is = Util.isString(str);
if (is) {
@ -348,6 +354,12 @@
return word;
}
function getRegStrEnd() {
var regStrEnd = '(\\s|\\;|&&|\\|\\|)';
return regStrEnd;
}
function log(connNum, str, typeParam) {
var ret,
type = ' ';