diff --git a/.eslintrc.js b/.eslintrc.js index c9196f6..74aabdc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { root: true, parserOptions: { - ecmaVersion: 6, + ecmaVersion: 'latest', sourceType: 'module' }, extends: 'eslint:recommended', diff --git a/lib/s3.js b/lib/s3.js index f090bde..a503336 100644 --- a/lib/s3.js +++ b/lib/s3.js @@ -166,7 +166,7 @@ module.exports = CoreObject.extend({ var revisionPrefix = joinUriSegments(prefix, options.filePattern + ":" + options.revisionKey); return listObjects({ Bucket: bucket, Prefix: revisionPrefix }) - .then((response) => response.Contents.find((element) => element.Key === revisionPrefix)); + .then((response) => response.Contents?.find((element) => element.Key === revisionPrefix)); }, fetchRevisions: function(options) { diff --git a/tests/unit/lib/s3-test.js b/tests/unit/lib/s3-test.js index 17c2ef3..9d499c2 100644 --- a/tests/unit/lib/s3-test.js +++ b/tests/unit/lib/s3-test.js @@ -242,6 +242,15 @@ describe('s3', function() { }); }); + it('succeeds when revision key search returns no values', function() { + s3Client.listObjects = function(params, cb) { + cb(undefined, {}); + }; + var promise = subject.upload(options); + + return assert.isFulfilled(promise); + }); + describe("when revisionKey was already uploaded", function() { beforeEach(function() { options.revisionKey = "123";