@alexbainter/s3-sync
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -48,2 +48,8 @@ #!/usr/bin/env node | ||
}, | ||
mutableHtml: { | ||
description: | ||
'(Optional) Treat all HTML files as mutable, even if not specified by --mutableFilenames', | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
compressExtensions: { | ||
@@ -183,2 +189,3 @@ alias: 'compress', | ||
aliasPages, | ||
mutableHtml, | ||
_, | ||
@@ -197,2 +204,3 @@ } = program.argv; | ||
cloudFront: distributionId && createCloudFront(distributionId), | ||
mutableHtml, | ||
}) | ||
@@ -199,0 +207,0 @@ .then(() => { |
@@ -16,2 +16,3 @@ 'use strict'; | ||
aliasHtmlPages = true, | ||
mutableHtml = true, | ||
} = {}) => | ||
@@ -21,13 +22,15 @@ getFilenames({ s3, distDir }).then(({ localFilenames, remoteFilenames }) => { | ||
const remoteFilenameSet = new Set(remoteFilenames); | ||
const htmlAliases = aliasHtmlPages | ||
? localFilenames | ||
.filter( | ||
(localFilename) => | ||
localFilename.endsWith('.html') && | ||
!localFilename.endsWith('index.html') | ||
) | ||
.map((localFilename) => localFilename.replace('.html', '')) | ||
: []; | ||
const htmlAliasSet = new Set( | ||
aliasHtmlPages | ||
? localFilenames | ||
.filter( | ||
(localFilename) => | ||
localFilename.endsWith('.html') && | ||
!localFilename.endsWith('index.html') | ||
) | ||
.map((localFilename) => localFilename.replace('.html', '')) | ||
: [] | ||
); | ||
const uploadFilenames = localFilenames | ||
.concat(htmlAliases) | ||
.concat(Array.from(htmlAliasSet)) | ||
.filter((localFilename) => { | ||
@@ -40,3 +43,5 @@ const destinationFilename = getRemoteDestinationFilename( | ||
mutableFilenameSet.has(destinationFilename) || | ||
!remoteFilenameSet.has(destinationFilename) | ||
!remoteFilenameSet.has(destinationFilename) || | ||
(mutableHtml && destinationFilename.endsWith('.html')) || | ||
(mutableHtml && htmlAliasSet.has(localFilename)) | ||
); | ||
@@ -64,4 +69,2 @@ }); | ||
const htmlAliasSet = new Set(htmlAliases); | ||
return Promise.all( | ||
@@ -68,0 +71,0 @@ uploadFilenames.map((localPath) => { |
{ | ||
"name": "@alexbainter/s3-sync", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Transfer files to and from S3", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -56,2 +56,9 @@ # @alexbainter/s3-sync | ||
##### Mutable HTML (optional) | ||
If enabled, treats all HTML files (and aliases, if applicable) as mutable. Defaults to `true`. | ||
- CLI: `--mutableHtml`, | ||
- Environment variable: `S3_SYNC_MUTABLE_HTML=<true/false>` | ||
##### Dry Run (optional) | ||
@@ -58,0 +65,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26802
711
115