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

Allow to work with more than just gulp-gzip #1

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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"through2": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.0.0",
Expand Down
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const PluginError = gutil.PluginError;
function getMetadata(file, extraMetadata = {}) {
const meta = {
...extraMetadata,
contentType: mime.lookup(file.path),
contentType: mime.lookup(file.path.replace(/\.gz$/, '')),
};

// Check if it's gziped
if (file.contentEncoding && file.contentEncoding.indexOf('gzip') > -1) {
// Check to see if it has a gz (Gzip) extension
if (file.extname == '.gz') {
meta.contentEncoding = 'gzip';
}
};

return meta;
}
Expand Down Expand Up @@ -144,7 +144,6 @@ function gPublish(options) {
return done(null, file);
}

file.path = file.path.replace(/\.gz$/, '');
const metadata = getMetadata(file, extraMetadata);

// Authenticate on Google Cloud Storage
Expand Down
5 changes: 1 addition & 4 deletions test/gcloud.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('gulp-gcloud-publish', function suite() {
.on('error', done);
});

it('should recognise a gzip and make it public', function test(done) {
it('should recognise a gzip and set contentEncoding', function test(done) {
createWriteStreamStub.returns(createFakeStream());
const fakeFile = new File({
contents: es.readArray(['stream', 'with', 'those', 'contents']),
Expand All @@ -105,8 +105,6 @@ describe('gulp-gcloud-publish', function suite() {
path: '/test/file.css.gz',
});

fakeFile.contentEncoding = ['gzip'];

const config = _.clone(exampleConfig);
config.public = true;

Expand All @@ -120,7 +118,6 @@ describe('gulp-gcloud-publish', function suite() {
contentEncoding: 'gzip',
});

assert.ifError(/\.gz$/.test(file.path));
done();
})
.on('error', done);
Expand Down