Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new file creation, when file updates are skipped #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Create a through stream, that push files to s3.
- noAcl: do not set x-amz-acl by default
- simulate: debugging option to simulate s3 upload
- createOnly: skip file updates
- newFile: create new file instead of skipping file updates

Files that go through the stream receive extra properties:

Expand Down
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ module.exports._toAwsParams = toAwsParams;
* @api private
*/

function initFile(file) {
if (!file.s3) {
function initFile(file, newFile) {
newFile = newFile || false;
if (!file.s3 || newFile) {
file.s3 = {};
file.s3.headers = {};
file.s3.path = file.relative.replace(/\\/g, '/');
Expand Down Expand Up @@ -320,7 +321,7 @@ Publisher.prototype.publish = function (headers, options) {
// check if file.contents is a `Buffer`
if (file.isBuffer()) {

initFile(file);
initFile(file, options.newFile);

// calculate etag
etag = '"' + md5Hash(file.contents) + '"';
Expand Down