@@ -6,6 +6,7 @@ const DEFAULTS = require('../../defaults');
6
6
const { workflow , pipeline } = require ( '../../../../logic' ) . api ;
7
7
const { specifyOutputForSingle, specifyOutputForArray } = require ( '../../helpers/get' ) ;
8
8
const getRoot = require ( '../root/get.cmd' ) ;
9
+ const { printError } = require ( '../../helpers/general' ) ;
9
10
10
11
const command = new Command ( {
11
12
command : 'workflows [id]' ,
@@ -61,18 +62,18 @@ const command = new Command({
61
62
workflows = await workflow . getWorkflowById ( workflowId ) ;
62
63
specifyOutputForSingle ( argv . output , workflows ) ;
63
64
} else {
64
- if ( _ . isEmpty ( pipelineIds ) && ! _ . isEmpty ( pipelineNames ) ) {
65
- const pipelines = await pipeline . getAll ( ) ;
66
- _ . forEach ( pipelineNames , ( pipelineName ) => {
67
- const matchPipelines = _ . find ( pipelines , pipeline => pipeline . info . name . toString ( ) === pipelineName ) ;
68
- if ( _ . isArray ( matchPipelines ) ) {
69
- _ . forEach ( matchPipelines , ( currPipeline ) => {
70
- pipelineIds . push ( currPipeline . info . id ) ;
71
- } ) ;
72
- } else {
73
- pipelineIds . push ( matchPipelines . info . id ) ;
74
- }
65
+ if ( ! _ . isEmpty ( pipelineNames ) ) {
66
+ const pipelines = await pipeline . getAll ( {
67
+ name : pipelineNames ,
75
68
} ) ;
69
+ if ( ! _ . isEmpty ( pipelines ) ) {
70
+ const MatchPipelines = _ . isArray ( pipelines ) ? pipelines : [ pipelines ] ;
71
+ _ . forEach ( MatchPipelines , ( currPipeline ) => {
72
+ pipelineIds . push ( currPipeline . info . id ) ;
73
+ } ) ;
74
+ } else if ( _ . isEmpty ( pipelineIds ) ) {
75
+ throw new CFError ( 'Cannot find any workflows with these pipelines names' ) ;
76
+ }
76
77
}
77
78
workflows = await workflow . getWorkflows ( {
78
79
limit,
0 commit comments