@@ -34,33 +34,35 @@ class ServerlessPlugin {
34
34
if ( ! this . shouldRun ( ) ) {
35
35
return ;
36
36
}
37
- const arn = await this . getArn ( ) ;
38
- if ( arn === undefined ) {
37
+ const arns = await this . getArns ( ) ;
38
+ if ( arns . length === 0 ) {
39
39
throw new Error ( 'Serverless Version Tracker error: cannot retrieve deployed ARN' ) ;
40
40
}
41
- const regex = / ( [ - \w ] * ) : ( \d * ) $ / ;
42
- const name = arn . match ( regex ) [ 1 ] ;
43
- const version = arn . match ( regex ) [ 2 ] ;
44
- const tag = `${ name } -${ version } ` ;
45
- this . serverless . cli . log ( `Creating local git tag '${ tag } '...` ) ;
46
- const { stdout, stderr } = await exec ( `git tag ${ tag } ` ) ;
47
- if ( stdout || stderr ) {
48
- throw new Error ( `stdout: ${ stdout } ; stderr: ${ stderr } ` ) ;
49
- }
41
+ arns . forEach ( async ( arn ) => {
42
+ const regex = / ( [ - \w ] * ) : ( \d * ) $ / ;
43
+ const name = arn . match ( regex ) [ 1 ] ;
44
+ const version = arn . match ( regex ) [ 2 ] ;
45
+ const tag = `${ name } -${ version } ` ;
46
+ this . serverless . cli . log ( `Creating local git tag '${ tag } '...` ) ;
47
+ const { stdout, stderr } = await exec ( `git tag ${ tag } ` ) ;
48
+ if ( stdout || stderr ) {
49
+ throw new Error ( `stdout: ${ stdout } ; stderr: ${ stderr } ` ) ;
50
+ }
51
+ } ) ;
50
52
}
51
53
52
- async getArn ( ) {
54
+ async getArns ( ) {
53
55
const resp = await this . provider . request ( 'CloudFormation' , 'describeStacks' , { StackName : this . provider . naming . getStackName ( this . stage ) } ) ;
54
56
const output = resp . Stacks [ 0 ] . Outputs ;
55
- let arn ;
56
- let arns ;
57
+ let arns = [ ] ;
58
+ let filteredOutputs ;
57
59
try {
58
- arns = output . filter ( entry => entry . OutputKey . match ( 'LambdaFunctionQualifiedArn' ) ) ;
60
+ filteredOutputs = output . filter ( entry => entry . OutputKey . match ( 'LambdaFunctionQualifiedArn' ) ) ;
59
61
} catch ( error ) {
60
- return arn ;
62
+ return arns ;
61
63
}
62
- arns . forEach ( ( entry ) => { arn = entry . OutputValue ; } ) ;
63
- return arn ;
64
+ filteredOutputs . forEach ( ( entry ) => { arns . push ( entry . OutputValue ) } ) ;
65
+ return arns
64
66
}
65
67
66
68
shouldRun ( ) {
0 commit comments