Skip to content

Commit

Permalink
filesUploaded should return all files uploaded with manifest
Browse files Browse the repository at this point in the history
`filesUploaded` is currently only `[manifest.txt]` if using a manifest
  • Loading branch information
wongpeiyi committed Aug 27, 2016
1 parent 4abd1ad commit 548606d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ module.exports = CoreObject.extend({

const manifestPath = options.manifestPath;
if (manifestPath) {
return allFilesUploaded.then(function() {
return Promise.all(this._putObjects([manifestPath], options));
return allFilesUploaded.then(function(filesUploaded) {
return Promise.all(this._putObjects([manifestPath], options)).then(function(manifestUploaded) {
return filesUploaded.concat(manifestUploaded);
});
}.bind(this));
} else {
return allFilesUploaded;
Expand Down
27 changes: 25 additions & 2 deletions tests/unit/lib/s3-nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,27 @@ describe('s3', function() {
assert.equal(s3Params.ContentType, 'application/octet-stream');
});
});

it('returns a promise with an array of the files uploaded', function() {
var s3Params;
s3Client.putObject = function(params, cb) {
s3Params = params;
cb();
};

var options = {
filePaths: ['app.js', 'app.css'],
cwd: process.cwd() + '/tests/fixtures/dist',
prefix: 'js-app'
};

var promises = subject.upload(options);

return assert.isFulfilled(promises)
.then(function(filesUploaded) {
assert.deepEqual(filesUploaded, ['app.js', 'app.css']);
});
});
});

describe('with a manifestPath specified', function () {
Expand All @@ -201,13 +222,14 @@ describe('s3', function() {
var promise = subject.upload(options);

return assert.isFulfilled(promise)
.then(function() {
.then(function(filesUploaded) {
assert.equal(mockUi.messages.length, 5);
assert.match(mockUi.messages[0], /- Downloading manifest for differential deploy.../);
assert.match(mockUi.messages[1], /- Manifest not found. Disabling differential deploy\./);
assert.match(mockUi.messages[2], /- ✔ js-app\/app\.js/);
assert.match(mockUi.messages[3], /- ✔ js-app\/app\.css/);
assert.match(mockUi.messages[4], /- ✔ js-app\/manifest\.txt/);
assert.deepEqual(filesUploaded, ['app.js', 'app.css', 'manifest.txt']);
done();
}).catch(function(reason) {
done(reason);
Expand All @@ -231,12 +253,13 @@ describe('s3', function() {
var promise = subject.upload(options);

return assert.isFulfilled(promise)
.then(function() {
.then(function(filesUploaded) {
assert.equal(mockUi.messages.length, 4);
assert.match(mockUi.messages[0], /- Downloading manifest for differential deploy.../);
assert.match(mockUi.messages[1], /- Manifest found. Differential deploy will be applied\./);
assert.match(mockUi.messages[2], /- ✔ js-app\/app\.css/);
assert.match(mockUi.messages[3], /- ✔ js-app\/manifest\.txt/);
assert.deepEqual(filesUploaded, ['app.css', 'manifest.txt']);
done();
}).catch(function(reason) {
done(reason);
Expand Down

0 comments on commit 548606d

Please sign in to comment.