mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(console) change console output on windows
This commit is contained in:
parent
81e75d9ca5
commit
8f6892c59f
3 changed files with 26 additions and 30 deletions
|
|
@ -23,6 +23,8 @@
|
|||
Minify = main.minify,
|
||||
Config = main.config,
|
||||
|
||||
win = require(DIR_SERVER + 'win'),
|
||||
|
||||
CONFIG_PATH = JSONDIR + 'config.json',
|
||||
|
||||
KEY = DIR + 'ssl/ssl.key',
|
||||
|
|
@ -47,6 +49,7 @@
|
|||
DIR = main.DIR;
|
||||
|
||||
readConfig(init);
|
||||
win.prepareCodePage();
|
||||
|
||||
/**
|
||||
* additional processing of index file
|
||||
|
|
|
|||
|
|
@ -29,24 +29,7 @@
|
|||
HELP = {
|
||||
stdout : CLOUDCMD + ' exit \n' +
|
||||
CLOUDCMD + ' update \n',
|
||||
},
|
||||
|
||||
/* windows commands thet require
|
||||
* unicode charset on locales
|
||||
* different then English
|
||||
*/
|
||||
Win32Commands = ['ASSOC', 'AT', 'ATTRIB', 'BREAK', 'CACLS', 'CALL',
|
||||
'CD', 'CHCP', 'CHDIR', 'CHKDSK', 'CHKNTFS', 'CLS',
|
||||
'CMD', 'COLOR', 'COMP', 'COMPACT', 'CONVERT', 'COPY',
|
||||
'DATE', 'DEL', 'DIR', 'DISKCOMP', 'DISKCOPY', 'DOSKEY',
|
||||
'ECHO', 'ENDLOCAL', 'ERASE', 'EXIT', 'FC', 'FIND',
|
||||
'FINDSTR', 'FOR', 'FORMAT', 'FTYPE', 'GOTO', 'GRAFTABL',
|
||||
'HELP', 'IF', 'LABEL', 'MD', 'MKDIR', 'MODE', 'MORE',
|
||||
'MOVE', 'PATH', 'PAUSE', 'POPD', 'PRINT', 'PROMPT',
|
||||
'PUSHD', 'RD', 'RECOVER', 'REM', 'REN', 'RENAME',
|
||||
'REPLACE', 'RMDIR', 'SET', 'SETLOCAL', 'SHIFT', 'SORT',
|
||||
'START', 'SUBST', 'TIME', 'TITLE', 'TREE', 'TYPE',
|
||||
'VER', 'VERIFY', 'VOL', 'XCOPY'];
|
||||
};
|
||||
|
||||
/**
|
||||
* function listen on servers port
|
||||
|
|
@ -140,18 +123,10 @@
|
|||
ClientDirs[connNum] = path;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (!ret) {
|
||||
/* if we on windows and command is build in
|
||||
* change code page to unicode becouse
|
||||
* windows use unicode on non English versions
|
||||
*/
|
||||
if (WIN32) {
|
||||
winCommand = command.toUpperCase();
|
||||
|
||||
if (Win32Commands.indexOf(winCommand) >= 0)
|
||||
command = 'chcp 65001 |' + command;
|
||||
}
|
||||
if (WIN32)
|
||||
command = 'cmd /C ' + command;
|
||||
|
||||
if (!ClientFuncs[connNum])
|
||||
ClientFuncs[connNum] = Util.exec.with(setExec, function(json, error, stderr) {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
*/
|
||||
|
||||
var spawn = require('child_process').spawn,
|
||||
exec = require('child_process').exec,
|
||||
DIR = '../',
|
||||
DIR_SERVER = DIR + 'server/',
|
||||
Util = require(DIR + 'util'),
|
||||
pipe = require(DIR_SERVER + 'pipe');
|
||||
|
||||
exports.getVolumes = getVolumes;
|
||||
exports.getVolumes = getVolumes;
|
||||
exports.prepareCodePage = prepareCodePage;
|
||||
|
||||
function getVolumes(callback) {
|
||||
var wmic = spawn('wmic', ['logicaldisk', 'get', 'name']);
|
||||
|
|
@ -56,4 +58,20 @@
|
|||
|
||||
callback(null, volumes);
|
||||
}
|
||||
|
||||
function prepareCodePage() {
|
||||
/* if we on windows and command is build in
|
||||
* change code page to unicode becouse
|
||||
* windows use unicode on non English versions
|
||||
*/
|
||||
|
||||
if (process.platform === 'win32')
|
||||
exec('chcp 65001', function(error, stdout, stderror) {
|
||||
if (error)
|
||||
console.log(error);
|
||||
|
||||
if (stderror)
|
||||
console.log(stderror);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue