Add more infomations to error object
This commit is contained in:
parent
c984c1b7be
commit
583cb4048a
3 changed files with 8 additions and 4 deletions
|
@ -26,7 +26,7 @@ while (typeof(arg = args.shift()) === 'string') {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof(options.display) === 'string' && options.display !== '') {
|
||||
if (typeof options.display === 'string' && options.display !== '') {
|
||||
ttyWrite(options.encoded ? decodeDOS(options.display) : options.display);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,9 @@ function _readlineShell(options) {
|
|||
res.error.command = SHELL_CMD;
|
||||
res.error.args = cmdArgs;
|
||||
res.error.shellMessage = e.stderr.trim();
|
||||
res.error.code = e.code;
|
||||
res.error.signal = e.signal;
|
||||
res.error.exitCode = e.status;
|
||||
}
|
||||
} else {
|
||||
res = _execSyncByFile(cmdArgs, execOptions);
|
||||
|
@ -196,7 +199,7 @@ function _execSyncByFile(cmdArgs, execOptions) {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
var execArgs, interpreter, res = {},
|
||||
var execArgs, interpreter, res = {}, exitCode,
|
||||
pathStdout = getTempfile('readline-sync.stdout'),
|
||||
pathStderr = getTempfile('readline-sync.stderr'),
|
||||
pathExit = getTempfile('readline-sync.exit'),
|
||||
|
@ -243,7 +246,7 @@ function _execSyncByFile(cmdArgs, execOptions) {
|
|||
}
|
||||
|
||||
while (fs.readFileSync(pathDone, {encoding: encoding}).trim() !== '1') {}
|
||||
if (fs.readFileSync(pathExit, {encoding: encoding}).trim() === '0') {
|
||||
if ((exitCode = fs.readFileSync(pathExit, {encoding: encoding}).trim()) === '0') {
|
||||
res.input =
|
||||
decipher.update(fs.readFileSync(pathStdout, {encoding: 'binary'}), 'hex', encoding) +
|
||||
decipher.final(encoding);
|
||||
|
@ -253,6 +256,7 @@ function _execSyncByFile(cmdArgs, execOptions) {
|
|||
res.error.command = SHELL_CMD;
|
||||
res.error.args = cmdArgs;
|
||||
res.error.shellMessage = fs.readFileSync(pathStderr, {encoding: encoding}).trim();
|
||||
res.error.exitCode = +exitCode;
|
||||
}
|
||||
|
||||
fs.unlinkSync(pathStdout);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "readline-sync",
|
||||
"version": "0.7.8",
|
||||
"version": "0.7.9",
|
||||
"title": "readlineSync",
|
||||
"description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).",
|
||||
"keywords": [
|
||||
|
|
Loading…
Reference in a new issue