Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
Fixed mime.lookup deprecation with mime.getType, closes #118
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Jun 19, 2018
1 parent 234746b commit e76ca00
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/main.js
Expand Up @@ -67,7 +67,7 @@ var createTag = function(src, asset, attributes, version) {
return src + asset + version;
}
// Check mime type
switch (mime.lookup(asset.split('?')[0])) {
switch (mime.getType(asset.split('?')[0])) {
case 'application/javascript':
case 'text/javascript':
attributes.type = attributes.type || 'text/javascript';
Expand Down Expand Up @@ -116,7 +116,7 @@ var renderTag = function(options, assets, attributes) {
type = '';
for (var b = 0; b < assets.length; b += 1) {
if (type === '')
type = mime.lookup(assets[b]);else if (mime.lookup(assets[b]) !== type)
type = mime.getType(assets[b]);else if (mime.getType(assets[b]) !== type)
throwError('mime types in CDN array of assets must all be the same');
// Push just the file name to the concat array
concat.push(path.basename(assets[b]));
Expand Down Expand Up @@ -245,7 +245,7 @@ var compile = function(fileName, assets, S3, options, method, type, timestamp, c
} else {
relativePath = path.join(assetBasePath, relativePath);
}
var mimeType = mime.lookup(relativePath);
var mimeType = mime.getType(relativePath);
var imageResource = compile(relativePath.substr(options.publicDir.length + 1), relativePath, S3, options, 'image', mimeType, Date.now(), null, null)();
return 'url(' + path.relative(fileBasePath, relativePath) + ')';
} else {
Expand All @@ -267,7 +267,7 @@ var compile = function(fileName, assets, S3, options, method, type, timestamp, c
} else {
relativePath = path.join(assetBasePath, relativePath);
}
var mimeType = mime.lookup(relativePath);
var mimeType = mime.getType(relativePath);
var fontResource = compile(relativePath.substr(options.publicDir.length + 1), relativePath, S3, options, 'font', mimeType, Date.now(), null, null)();
return 'url(' + path.relative(fileBasePath, relativePath) + ')';
} else {
Expand Down Expand Up @@ -401,7 +401,7 @@ var checkStringIfModified = function(assets, fileName, S3, options, timestamp, c
message: '"' + fileName + '" was not found on S3 or was modified recently'
});
// Check file type
var type = mime.lookup(assets);
var type = mime.getType(assets);
switch (type) {
case 'application/javascript':
case 'text/javascript':
Expand Down Expand Up @@ -456,7 +456,7 @@ var processAssets = function(options, results, done) {
// Ensure all assets are of the same type
for (var k = 0; k < assets.length; k += 1) {
if (type === '')
type = mime.lookup(assets[k]);else if (mime.lookup(assets[k]) !== type)
type = mime.getType(assets[k]);else if (mime.getType(assets[k]) !== type)
throwError('mime types in array do not match');
assets[k] = path.join(options.publicDir, assets[k]);
timestamp = Math.max(timestamp, fs.statSync(assets[k]).mtime.getTime());
Expand Down

0 comments on commit e76ca00

Please sign in to comment.