Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ function _list(opts) {
let profile = opts.profile;
let manifestKey = opts.manifestKey

let client = new AWS.S3({
accessKeyId,
secretAccessKey,
region
});

if (profile) {
console.log('using profile: ' + profile);
AWS.config.credentials = new AWS.SharedIniFileCredentials({
profile: profile
});
}

let client = new AWS.S3({
accessKeyId,
secretAccessKey,
region
});

let listObjects = RSVP.denodeify(client.listObjects.bind(client));
let getObject = RSVP.denodeify(client.getObject.bind(client));

Expand All @@ -40,11 +41,12 @@ function _list(opts) {
.then((current) => {
return { revisions: revisionsResults, current };
})
.catch(() => {
.catch((error) => {
console.error('failed to get revisions: ' + error);
return { revisions: revisionsResults, current: { Body: '{}'} };
})
.then((result) => {
if (result.revisions.length < 1) {
if (!result.revisions || result.revisions.length < 1) {
return { revisions: [] };
}

Expand Down Expand Up @@ -182,14 +184,15 @@ module.exports = {
let archivePrefix = this.readConfig('archivePrefix');
let bucket = this.readConfig('bucket');
let region = this.readConfig('region');
let profile = this.readConfig('profile');
let manifestKey = this.readConfig('manifestKey');
let awsPrefix = this.readConfig('awsPrefix');

archivePrefix = awsPrefix ? `${awsPrefix}/${archivePrefix}` : archivePrefix;
manifestKey = awsPrefix ? `${awsPrefix}/${manifestKey}` : manifestKey;

let opts = {
accessKeyId, secretAccessKey, archivePrefix, bucket, region, manifestKey
accessKeyId, secretAccessKey, archivePrefix, bucket, region, profile, manifestKey
};

return _list(opts)
Expand Down Expand Up @@ -219,7 +222,7 @@ module.exports = {
accessKeyId, secretAccessKey, archivePrefix, bucket, region, profile, manifestKey
};

return _list(opts, this)
return _list(opts)
.then((data) => {
let revisions = data.revisions;
revisions.forEach(r => {
Expand Down