mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(console) change volume in windows
This commit is contained in:
parent
2775d4cfc6
commit
7ebfd53ec3
1 changed files with 40 additions and 13 deletions
|
|
@ -97,6 +97,8 @@
|
|||
var funcExec, firstChar,
|
||||
connName, ret, isContain,
|
||||
|
||||
isVolume = isChangeWinVolume(command),
|
||||
|
||||
symbolsExec = ['*', '&', '{', '}', '|', '\'', '"'],
|
||||
CWD = process.cwd(),
|
||||
dir = ClientDirs[connNum],
|
||||
|
|
@ -112,7 +114,7 @@
|
|||
|
||||
if (equalPart(command, CLOUDCMD))
|
||||
ret = onCloudCmd(command, callback);
|
||||
else if (equalPart(command, 'cd ')) {
|
||||
else if (equalPart(command, 'cd ') || isVolume) {
|
||||
ret = true;
|
||||
|
||||
onCD(command, dir, function(error, json) {
|
||||
|
|
@ -262,30 +264,55 @@
|
|||
return is;
|
||||
}
|
||||
|
||||
function onCD(command, currDir, callback) {
|
||||
var dir,
|
||||
getDir = WIN32 ? 'chdir' : 'pwd',
|
||||
paramDir = Util.rmStr(command, 'cd ');
|
||||
function onCD(command, currDir, callback) {
|
||||
var isChangeVolume = isChangeWinVolume(command),
|
||||
isVolume = isWinVolume(command),
|
||||
paramDir = Util.rmStr(command, 'cd '),
|
||||
isRootOrHome = equalPart(paramDir, ['/', '~']),
|
||||
getDir = WIN32 ? 'chdir' : 'pwd';
|
||||
|
||||
if (equalPart(paramDir, ['/', '~']))
|
||||
dir = paramDir;
|
||||
else
|
||||
dir = path.join(currDir, paramDir);
|
||||
if (!isRootOrHome && !isChangeVolume || isVolume)
|
||||
command = 'cd ' + path.join(currDir, paramDir);
|
||||
|
||||
exec('cd ' + dir + ' && ' + getDir, function (error, stdout, stderr) {
|
||||
exec(command + ' && ' + getDir, {cwd : currDir}, function (error, stdout, stderr) {
|
||||
var errorStr = '',
|
||||
errorData = error || stderr;
|
||||
errorData = stderr || error,
|
||||
isStr = Util.isString(errorData);
|
||||
|
||||
if (errorData)
|
||||
if (errorData && !isStr)
|
||||
errorStr = Util.stringifyJSON(errorData);
|
||||
else
|
||||
errorStr = errorData;
|
||||
|
||||
callback(errorData, {
|
||||
Util.exec(callback, {
|
||||
stderr : errorStr,
|
||||
path : CloudFunc.rmNewLine(stdout)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function isWinVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
if (WIN32) {
|
||||
winVolume = new RegExp('^[a-z]{1}:\\\\.*', 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
function isChangeWinVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
if (WIN32) {
|
||||
winVolume = new RegExp('^[a-z]{1}:$', 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
function log(connNum, str, typeParam) {
|
||||
var ret,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue