Skip to content

Commit

Permalink
feat: update to inline-source 6.1.8 (#48)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: requires a minimum Node version of 7.6
  • Loading branch information
makbol authored and fmal committed Nov 20, 2018
1 parent e36a083 commit 2ed7510
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
23 changes: 10 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var inlineSource = require('inline-source'),
var { inlineSource } = require('inline-source'),
PluginError = require('plugin-error'),
path = require('path'),
through = require('through2');
Expand All @@ -8,7 +8,7 @@ const PLUGIN_NAME = 'gulp-inline-source';
function gulpInlineSource (options) {
'use strict';

var stream = through.obj(function (file, enc, cb) {
return through.obj(function (file, enc, cb) {
var self = this;

if (file.isNull() || file.isDirectory()) {
Expand All @@ -32,19 +32,16 @@ function gulpInlineSource (options) {
}
}

inlineSource(file.contents.toString(), fileOptions, function (err, html) {
if (err) {
self.emit('error', new PluginError(PLUGIN_NAME, err));
} else {
file.contents = new Buffer(html || '');
inlineSource(file.contents.toString(), fileOptions)
.then(html => {
file.contents = Buffer.from(html || '');
self.push(file);
}

cb();
});
cb();
})
.catch(err => {
self.emit('error', new PluginError(PLUGIN_NAME, err));
});
});

return stream;
}

module.exports = gulpInlineSource;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"plugin-error": "~1.0.1",
"inline-source": "~5.2.6",
"inline-source": "~6.1.8",
"through2": "~2.0.0"
},
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion test/expected/inlined-image-png.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<head>
</head>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAKtJREFUaAXt0rERwDAMw0A5+++cuEiHDSD4Tg078n1m5r235j1rmv5FK2wXTzhh2QJ9aRko6iSMSWRBwjJQ1EkYk8iChGWgqJMwJpEFCctAUSdhTCILEpaBok7CmEQWJCwDRZ2EMYksSFgGijoJYxJZkLAMFHUSxiSyIGEZKOokjElkQcIyUNRJGJPIgoRloKiTMCaRBQnLQFEnYUwiCxKWgaJOwphEFqwT/gC5HwF3y7W1swAAAABJRU5ErkJggg==" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAKtJREFUaAXt0rERwDAMw0A5+++cuEiHDSD4Tg078n1m5r235j1rmv5FK2wXTzhh2QJ9aRko6iSMSWRBwjJQ1EkYk8iChGWgqJMwJpEFCctAUSdhTCILEpaBok7CmEQWJCwDRZ2EMYksSFgGijoJYxJZkLAMFHUSxiSyIGEZKOokjElkQcIyUNRJGJPIgoRloKiTMCaRBQnLQFEnYUwiCxKWgaJOwphEFqwT/gC5HwF3y7W1swAAAABJRU5ErkJggg=="/>
</body>
</html>
2 changes: 1 addition & 1 deletion test/expected/inlined-image-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<head>
</head>
<body>
<svg width="60" height="60" viewBox="0 0 60 60"><title>Slice 1</title><path fill="#000" d="M0 0h60v60H0z" fill-rule="evenodd"/></svg>
<svg width="60" height="60" viewBox="0 0 60 60"><path fill="#000" d="M0 0h60v60H0z" fill-rule="evenodd"/></svg>
</body>
</html>

0 comments on commit 2ed7510

Please sign in to comment.