Skip to content

Commit d9e5c8c

Browse files
authored
Merge pull request #20 from MouadBelbah/fix/get-latest-function-version
Return latest lambda function with explicit version number
2 parents 589b052 + 691bb59 commit d9e5c8c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

deploy.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ const getLatestVersion = lambdaMapping =>
4444
getLastPageOfVersions(lambdaMapping)
4545
.then(
4646
res =>
47-
res.Versions.sort(
48-
(a, b) => (parseInt(a.Version) > parseInt(b.Version) ? -1 : 1)
49-
)[0]
47+
res.Versions.reduce((prev, curr) => (
48+
isNaN(curr.Version)
49+
|| parseInt(prev.Version) > parseInt(curr.Version) ? prev : curr
50+
))
5051
)
5152
.then(latest => ({
5253
EventType: lambdaMapping.EventType,

0 commit comments

Comments
 (0)