Comparing version 0.5.0 to 0.5.1
@@ -14,2 +14,4 @@ import * as inversify_lib_interfaces_interfaces from 'inversify/lib/interfaces/interfaces'; | ||
interface CommandArgs { | ||
'$?'?: CommandResult; | ||
'$!'?: unknown; | ||
} | ||
@@ -26,3 +28,3 @@ type CommandResult = number | void; | ||
} | ||
type ErrorHandler = (error: unknown, context: ErrorHandlerContext) => number; | ||
type ErrorHandler = (error: {}, context: ErrorHandlerContext) => number | Promise<number>; | ||
interface ErrorHandlerContext { | ||
@@ -29,0 +31,0 @@ stdout: Writable; |
@@ -138,11 +138,7 @@ "use strict"; | ||
var defualtErrorHandler = /* @__PURE__ */ __name((error, { stderr }) => { | ||
const message = error.message; | ||
if (message != null) { | ||
stderr.write(message); | ||
if (error.message != null) { | ||
stderr.write(error.message); | ||
stderr.write("\n"); | ||
} | ||
if (error instanceof CLIError) { | ||
return error.exitCode; | ||
} | ||
return 1; | ||
return error.exitCode ?? 1; | ||
}, "defualtErrorHandler"); | ||
@@ -172,3 +168,4 @@ | ||
return new Promise((resolve) => { | ||
this.yargs.parse(processArgs, {}, (error, argv, output) => { | ||
this.yargs.parse(processArgs, {}, (yargsError, argv, yargsOutput) => { | ||
const error = yargsError ?? argv["$!"]; | ||
if (error != null) { | ||
@@ -179,9 +176,10 @@ resolve(this.onError(error, { | ||
})); | ||
} else if (output !== "") { | ||
writeln(stdout, output); | ||
return; | ||
} | ||
if (yargsOutput !== "") { | ||
writeln(stdout, yargsOutput); | ||
resolve(0); | ||
} else { | ||
const exitCode = argv["$?"]; | ||
resolve(exitCode != null ? Number(exitCode) : 0); | ||
return; | ||
} | ||
resolve(argv["$?"] != null ? Number(argv["$?"]) : 0); | ||
}); | ||
@@ -202,4 +200,7 @@ }); | ||
const command = await container.getAsync(Command2); | ||
const commandResult = await command.execute(); | ||
args["$?"] = commandResult ?? 0; | ||
try { | ||
args["$?"] = await command.execute(); | ||
} catch (error) { | ||
args["$!"] = error; | ||
} | ||
}); | ||
@@ -206,0 +207,0 @@ this.isInit = true; |
{ | ||
"name": "sgray", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"author": "cumul <gg6123@naver.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40877
437