Skip to content

Commit

Permalink
fix: use basename instead of parse
Browse files Browse the repository at this point in the history
To continue to have A+ support (specifically path.parse doesn't exist in [email protected])
  • Loading branch information
remy committed Jul 31, 2016
1 parent 03f9ea6 commit 51ff9dd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {

var Promise = require('es6-promise').Promise; // jshint ignore:line
var debug = require('debug')('inliner');
var parse = require('path').parse;
var basename = require('path').basename;

function getImages(root, css) {
var inliner = this;
Expand Down Expand Up @@ -68,7 +68,7 @@ function getImports(root, css) {
return inliner.get(resolvedURL).then(function then(res) {
var importedCSS = res.body;
inliner.jobs.done.links();
inliner.emit('progress', 'import ' + parse(resolvedURL).base);
inliner.emit('progress', 'import ' + basename(resolvedURL));
if (url.length > 1) {
url.shift();
importedCSS = '@media ' + url.join(' ') + '{' + importedCSS + '}';
Expand Down
4 changes: 2 additions & 2 deletions lib/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var debug = require('debug')('inliner');
var Promise = require('es6-promise').Promise; // jshint ignore:line
var fs = require('then-fs');
var mime = require('mime');
var parse = require('path').parse;
var basename = require('path').basename;

var cache = {};

Expand All @@ -25,7 +25,7 @@ module.exports = function get(url, options) {
return cache[url];
}

var base = parse(url).base;
var base = basename(url);

this.emit('progress', 'loading ' + base);

Expand Down
4 changes: 2 additions & 2 deletions lib/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var debug = require('debug')('inliner');
var mime = require('mime');
var SVGO = require('svgo');
var svgo = new SVGO();
var parse = require('path').parse;
var basename = require('path').basename;
var Promise = require('es6-promise').Promise; // jshint ignore:line

function image(url) {
url = url.replace(/\??#.*$/, '');
var inliner = this;
this.emit('progress', 'get image ' + parse(url).base);
this.emit('progress', 'get image ' + basename(url));
return this.get(url, { encoding: 'binary' }).then(function then(res) {
if (url.indexOf('data:') === 0) {
return url;
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/favicon.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module.exports = resolve;
var debug = require('debug')('inliner');
var parse = require('path').parse;
var basename = require('path').basename;

function resolve(inliner, todo, $) {
debug('start %s favicon', todo.length);
return todo.map(function links(link) {
var url = inliner.resolve(inliner.url, $(link).attr('href'));
inliner.emit('progress', 'processing favicon ' + parse(url).base);
inliner.emit('progress', 'processing favicon ' + basename(url));
return inliner.image(url).then(function then(dataURL) {
$(link).attr('href', dataURL);
}).then(inliner.jobs.done.favicon);
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = resolve;

var Promise = require('es6-promise').Promise; // jshint ignore:line
var debug = require('debug')('inliner');
var parse = require('path').parse;
var basename = require('path').basename;

function resolve(inliner, todo, $) {
debug('start %s scripts', todo.length);
Expand All @@ -24,7 +24,7 @@ function resolve(inliner, todo, $) {
isMinified = src.indexOf('.min.') !== -1;
if (isMinified && !inliner.options.inlinemin) {
debug('skipping pre-minified script');
inliner.emit('progress', 'skipping minified script ' + parse(src).base);
inliner.emit('progress', 'skipping minified script ' + basename(src));
inliner.jobs.done.js();
// ignore scripts with .min. in them - i.e. avoid minify
// scripts that are already minifed
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/links.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = resolve;
var debug = require('debug')('inliner');
var parse = require('path').parse;
var basename = require('path').basename;

function resolve(inliner, todo, $) {
debug('start %s links', todo.length);
Expand All @@ -15,7 +15,7 @@ function resolve(inliner, todo, $) {
inliner.emit('progress', 'skipping remote links');
return false;
}
inliner.emit('progress', 'processing external css ' + parse(url).base);
inliner.emit('progress', 'processing external css ' + basename(url));
return inliner.get(url).then(function then(res) {
var css = res.body;
inliner.jobs.done.links();
Expand Down

0 comments on commit 51ff9dd

Please sign in to comment.