mirror of
https://github.com/remy/inliner.git
synced 2024-08-16 20:00:35 +03:00
feat: warn out when failing to get url on cli
Also cleaned up js uglify process as it was failing the test source.body when in fact there was a body, it was just empty.
This commit is contained in:
parent
8af810faa7
commit
c66d95deda
@ -53,6 +53,10 @@ function main() {
|
||||
pkg: defaults(pkg, { version: '0.0.0' }),
|
||||
}).notify();
|
||||
|
||||
inliner.on('warning', function progress(event) {
|
||||
console.warn('warning: ' + event);
|
||||
});
|
||||
|
||||
if (argv.verbose) {
|
||||
inliner.on('progress', function progress(event) {
|
||||
console.error(event);
|
||||
|
@ -7,6 +7,7 @@ var mime = require('mime');
|
||||
var cache = {};
|
||||
|
||||
module.exports = function get(url, options) {
|
||||
var inliner = this;
|
||||
if (url.indexOf('data:') === 0) {
|
||||
debug('asset already inline', url);
|
||||
return Promise.resolve({
|
||||
@ -61,6 +62,7 @@ module.exports = function get(url, options) {
|
||||
debug('response: %s %s', res.statusCode, url);
|
||||
if (res.statusCode !== 200) {
|
||||
body = '';
|
||||
inliner.emit('warning', res.statusCode + ' on ' + url);
|
||||
}
|
||||
|
||||
resolve({
|
||||
|
@ -146,10 +146,6 @@ function main() {
|
||||
var cheerioLoadOptions = {};
|
||||
var enc = inliner.options.encoding;
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
inliner.emit('progress', res.statusCode + ' on ' + url);
|
||||
}
|
||||
|
||||
// try to determine the encoding from the headers and the body
|
||||
if (!enc) {
|
||||
enc = charset(res.headers, res.body);
|
||||
|
@ -6,16 +6,17 @@ var UglifyJS = require('uglify-js');
|
||||
function uglify(source) {
|
||||
this.emit('progress', 'compressing javascript');
|
||||
|
||||
if (source.body === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (source.body) {
|
||||
if (source.body !== undefined) {
|
||||
source = source.body;
|
||||
}
|
||||
|
||||
// in case of local buffer
|
||||
source = source.toString();
|
||||
|
||||
if (source.trim() === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
debug('uglifying %sbytes', source.length);
|
||||
|
||||
return UglifyJS.minify(source, {
|
||||
|
Loading…
Reference in New Issue
Block a user