From 2ed7510fe6d21290720203e8cacd6ae2e578d759 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 21 Nov 2018 00:49:13 +0100 Subject: [PATCH] feat: update to inline-source 6.1.8 (#48) BREAKING CHANGE: requires a minimum Node version of 7.6 --- index.js | 23 ++++++++++------------- package.json | 2 +- test/expected/inlined-image-png.html | 2 +- test/expected/inlined-image-svg.html | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 2509fb6..3d6c2f9 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -var inlineSource = require('inline-source'), +var { inlineSource } = require('inline-source'), PluginError = require('plugin-error'), path = require('path'), through = require('through2'); @@ -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()) { @@ -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; diff --git a/package.json b/package.json index 20b79f0..756e835 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/expected/inlined-image-png.html b/test/expected/inlined-image-png.html index 20d1a62..84bf214 100644 --- a/test/expected/inlined-image-png.html +++ b/test/expected/inlined-image-png.html @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/test/expected/inlined-image-svg.html b/test/expected/inlined-image-svg.html index bd245c4..9ca1560 100644 --- a/test/expected/inlined-image-svg.html +++ b/test/expected/inlined-image-svg.html @@ -2,6 +2,6 @@ - Slice 1 +