@noravel/command 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Command.d.ts +1 -1
- package/dist/Contracts/Command.d.ts +1 -1
- package/dist/Executor.d.ts +1 -1
- package/dist/Executor.js +2 -1
- package/dist/Kernel.d.ts +1 -1
- package/dist/Kernel.js +10 -9
- package/dist/MakerCommand.d.ts +1 -1
- package/dist/MakerCommand.js +1 -1
- package/package.json +1 -1
package/dist/Command.d.ts
CHANGED
package/dist/Executor.d.ts
CHANGED
package/dist/Executor.js
CHANGED
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
class Executor {
|
|
4
4
|
static async call(command, argv) {
|
|
5
5
|
const commandInstance = new command(argv).bootstrap();
|
|
6
|
-
|
|
6
|
+
const exitCode = await commandInstance.handle();
|
|
7
|
+
return exitCode ? 1 : 0;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
exports.default = Executor;
|
package/dist/Kernel.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default class Kernel {
|
|
|
8
8
|
private output;
|
|
9
9
|
constructor(argv?: string[]);
|
|
10
10
|
register(commands: (new (argv: string[]) => CommandContract)[]): this;
|
|
11
|
-
run():
|
|
11
|
+
run(): Promise<0 | 1>;
|
|
12
12
|
setCallbackVersion(callback: () => void): this;
|
|
13
13
|
showVersion(): void;
|
|
14
14
|
getVersion(): any;
|
package/dist/Kernel.js
CHANGED
|
@@ -26,21 +26,21 @@ class Kernel {
|
|
|
26
26
|
this.registeredCommands = [...this.registeredCommands, ...commands];
|
|
27
27
|
return this;
|
|
28
28
|
}
|
|
29
|
-
run() {
|
|
29
|
+
async run() {
|
|
30
30
|
if (!this.name) {
|
|
31
31
|
const helper = new Helper_1.default();
|
|
32
32
|
helper.showHelpForMain(this.registeredCommands.map(command => new command(this.argv).bootstrap()));
|
|
33
|
-
return;
|
|
33
|
+
return 0;
|
|
34
34
|
}
|
|
35
35
|
let signatures = [];
|
|
36
36
|
if (['--help', '-h'].includes(this.name)) {
|
|
37
37
|
const helper = new Helper_1.default();
|
|
38
38
|
helper.showHelpForMain(this.registeredCommands.map(command => new command(this.argv).bootstrap()));
|
|
39
|
-
return;
|
|
39
|
+
return 0;
|
|
40
40
|
}
|
|
41
41
|
if (['--version', '-v'].includes(this.name)) {
|
|
42
42
|
this.showVersion();
|
|
43
|
-
return;
|
|
43
|
+
return 0;
|
|
44
44
|
}
|
|
45
45
|
for (const command of this.registeredCommands) {
|
|
46
46
|
const commandInstance = new command(this.argv).bootstrap();
|
|
@@ -50,23 +50,24 @@ class Kernel {
|
|
|
50
50
|
commandInstance.detect();
|
|
51
51
|
if (commandInstance.getOption('help')) {
|
|
52
52
|
commandInstance.showHelp();
|
|
53
|
-
return;
|
|
53
|
+
return 0;
|
|
54
54
|
}
|
|
55
55
|
if (commandInstance.getOption('version')) {
|
|
56
56
|
this.showVersion();
|
|
57
|
-
return;
|
|
57
|
+
return 0;
|
|
58
58
|
}
|
|
59
|
-
commandInstance.handle();
|
|
60
|
-
return;
|
|
59
|
+
const result = await commandInstance.handle();
|
|
60
|
+
return result ? 1 : 0;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
const suggestions = (0, didyoumean2_1.default)(this.name, signatures);
|
|
64
64
|
if (suggestions) {
|
|
65
65
|
this.output.error(`Command "${this.name}" is not defined. Did you mean "${suggestions}"?`);
|
|
66
|
-
return;
|
|
66
|
+
return 1;
|
|
67
67
|
}
|
|
68
68
|
this.output.error(`Command "${this.name}" is not defined. Did you mean one of these?`);
|
|
69
69
|
signatures.forEach(signature => this.output.comment(` ${signature}`));
|
|
70
|
+
return 1;
|
|
70
71
|
}
|
|
71
72
|
setCallbackVersion(callback) {
|
|
72
73
|
this.callbackVersion = callback.bind(this);
|
package/dist/MakerCommand.d.ts
CHANGED
package/dist/MakerCommand.js
CHANGED