Skip to content

Commit 3c0f924

Browse files
Itai GendlerItai Gendler
authored andcommitted
In case of unhandled rejection or uncaught exception, print error with middleware
1 parent 61e3035 commit 3c0f924

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

lib/interface/cli/codefresh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ const authManager = require('../../logic').auth.manager;
1010
const { printError } = require('./helpers/general');
1111

1212
process.on('uncaughtException', function (err) {
13-
console.error('uncaughtException', err.stack);
13+
printError(err);
14+
process.exit(1);
1415
});
1516

1617
process.on('unhandledRejection', error => {
17-
// Will print "unhandledRejection err is not defined"
18-
console.error('unhandledRejection', error.stack);
18+
printError(error);
19+
process.exit(1);
1920
});
2021

2122

lib/interface/cli/commands/trigger/event/get.cmd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const { specifyOutputForSingle, specifyOutputForArray } = require('../../../help
77
const getRoot = require('../../root/get.cmd');
88

99
const command = new Command({
10-
command: 'trigger-event [event-uri]',
10+
command: 'trigger-events [event-uri]',
11+
aliases: ['trigger-event'],
1112
parent: getRoot,
1213
description: 'Get `trigger-event`',
1314
webDocs: {

lib/interface/cli/commands/trigger/type/get.cmd.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { specifyOutputForSingle, specifyOutputForArray } = require('../../../help
77
const getRoot = require('../../root/get.cmd');
88

99
const command = new Command({
10-
command: 'trigger-types [type] [kind]',
10+
command: 'trigger-types',
1111
parent: getRoot,
1212
description: 'Get a list of system-wide available `trigger-types` or specified `trigger-type`',
1313
webDocs: {
@@ -16,11 +16,11 @@ const command = new Command({
1616
},
1717
builder: (yargs) => {
1818
yargs
19-
.positional('type', {
20-
describe: '`trigger-type` type name (e.g. `registry`, `cron`)',
19+
.option('type', {
20+
describe: 'filter by a specific trigger type (e.g. `registry`, `cron`)',
2121
})
22-
.positional('kind', {
23-
describe: '`trigger-type` kind (e.g. `dockerhub`, `cfcr`, `gcr`, `acr`); only some `trigger-types` may have kinds',
22+
.option('kind', {
23+
describe: 'filter by a specific trigger kind (e.g. `dockerhub`, `cfcr`, `gcr`, `acr`); only some `trigger-types` may have kinds',
2424
})
2525
.example('codefresh get trigger-types --type registry', 'Get Docker registry trigger types');
2626
},
@@ -35,6 +35,17 @@ const command = new Command({
3535
types = await trigger.getType(type, kind);
3636
} else {
3737
types = await trigger.getAllTypes();
38+
types = _.filter(types, (t) => {
39+
if (type && kind) {
40+
return t.info.type === type && t.info.kind === kind;
41+
} else if (type) {
42+
return t.info.type === type;
43+
} else if (kind) {
44+
return t.info.kind === kind;
45+
} else {
46+
return true;
47+
}
48+
});
3849
}
3950

4051
if (_.isArray(types)) {

0 commit comments

Comments
 (0)