Skip to content

Commit 2ed7510

Browse files
makbolfmal
authored andcommitted
feat: update to inline-source 6.1.8 (#48)
BREAKING CHANGE: requires a minimum Node version of 7.6
1 parent e36a083 commit 2ed7510

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

index.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var inlineSource = require('inline-source'),
1+
var { inlineSource } = require('inline-source'),
22
PluginError = require('plugin-error'),
33
path = require('path'),
44
through = require('through2');
@@ -8,7 +8,7 @@ const PLUGIN_NAME = 'gulp-inline-source';
88
function gulpInlineSource (options) {
99
'use strict';
1010

11-
var stream = through.obj(function (file, enc, cb) {
11+
return through.obj(function (file, enc, cb) {
1212
var self = this;
1313

1414
if (file.isNull() || file.isDirectory()) {
@@ -32,19 +32,16 @@ function gulpInlineSource (options) {
3232
}
3333
}
3434

35-
inlineSource(file.contents.toString(), fileOptions, function (err, html) {
36-
if (err) {
37-
self.emit('error', new PluginError(PLUGIN_NAME, err));
38-
} else {
39-
file.contents = new Buffer(html || '');
35+
inlineSource(file.contents.toString(), fileOptions)
36+
.then(html => {
37+
file.contents = Buffer.from(html || '');
4038
self.push(file);
41-
}
42-
43-
cb();
44-
});
39+
cb();
40+
})
41+
.catch(err => {
42+
self.emit('error', new PluginError(PLUGIN_NAME, err));
43+
});
4544
});
46-
47-
return stream;
4845
}
4946

5047
module.exports = gulpInlineSource;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"plugin-error": "~1.0.1",
24-
"inline-source": "~5.2.6",
24+
"inline-source": "~6.1.8",
2525
"through2": "~2.0.0"
2626
},
2727
"main": "index.js",

test/expected/inlined-image-png.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<head>
33
</head>
44
<body>
5-
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAKtJREFUaAXt0rERwDAMw0A5+++cuEiHDSD4Tg078n1m5r235j1rmv5FK2wXTzhh2QJ9aRko6iSMSWRBwjJQ1EkYk8iChGWgqJMwJpEFCctAUSdhTCILEpaBok7CmEQWJCwDRZ2EMYksSFgGijoJYxJZkLAMFHUSxiSyIGEZKOokjElkQcIyUNRJGJPIgoRloKiTMCaRBQnLQFEnYUwiCxKWgaJOwphEFqwT/gC5HwF3y7W1swAAAABJRU5ErkJggg==" />
5+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAKtJREFUaAXt0rERwDAMw0A5+++cuEiHDSD4Tg078n1m5r235j1rmv5FK2wXTzhh2QJ9aRko6iSMSWRBwjJQ1EkYk8iChGWgqJMwJpEFCctAUSdhTCILEpaBok7CmEQWJCwDRZ2EMYksSFgGijoJYxJZkLAMFHUSxiSyIGEZKOokjElkQcIyUNRJGJPIgoRloKiTMCaRBQnLQFEnYUwiCxKWgaJOwphEFqwT/gC5HwF3y7W1swAAAABJRU5ErkJggg=="/>
66
</body>
77
</html>

test/expected/inlined-image-svg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<head>
33
</head>
44
<body>
5-
<svg width="60" height="60" viewBox="0 0 60 60"><title>Slice 1</title><path fill="#000" d="M0 0h60v60H0z" fill-rule="evenodd"/></svg>
5+
<svg width="60" height="60" viewBox="0 0 60 60"><path fill="#000" d="M0 0h60v60H0z" fill-rule="evenodd"/></svg>
66
</body>
77
</html>

0 commit comments

Comments
 (0)