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
10 changes: 7 additions & 3 deletions tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module.exports = function(options) {
if (err) {
deferred.reject(err);
} else {
// trim the precedeing slash
if ( '/' == defaultRootObject.charAt( 0 ) ) {
defaultRootObject = defaultRootObject.substr(1);
}

// AWS Service returns errors if we don't fix these
if (data.DistributionConfig.Comment === null) data.DistributionConfig.Comment = '';
Expand All @@ -36,13 +40,13 @@ module.exports = function(options) {
data.DistributionConfig.Origins.Items[0].S3OriginConfig.OriginAccessIdentity = '';
}

if (data.DistributionConfig.DefaultRootObject === defaultRootObject.substr(1)) {
if (data.DistributionConfig.DefaultRootObject === defaultRootObject) {
gutil.log('gulp-cloudfront:', "DefaultRootObject hasn't changed, not updating.");
return deferred.resolve();
}

// Update the distribution with the new default root object (trim the precedeing slash)
data.DistributionConfig.DefaultRootObject = defaultRootObject.substr(1);
data.DistributionConfig.DefaultRootObject = defaultRootObject;

cloudfront.updateDistribution({
IfMatch: data.ETag,
Expand All @@ -53,7 +57,7 @@ module.exports = function(options) {
if (err) {
deferred.reject(err);
} else {
gutil.log('gulp-cloudfront:', 'DefaultRootObject updated to [' + defaultRootObject.substr(1) + '].');
gutil.log('gulp-cloudfront:', 'DefaultRootObject updated to [' + defaultRootObject + '].');
deferred.resolve();
}

Expand Down