Skip to content

Commit

Permalink
refactor: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Aug 30, 2020
1 parent ca9445b commit 98523d2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ const processHtml = require('./process-html')
const PLUGIN_NAME = 'gulp-lqip-base64'

const lqipBase64 = options => {
return through.obj(async (file, _, callback) => {
try {
if (file.isNull()) {
return callback(null, file)
}

if (file.isStream()) {
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'))
}
return through.obj((file, _, callback) => {
if (file.isNull()) {
return callback(null, file)
}

const newFile = await processHtml(file, options)
callback(null, newFile)
} catch (err) {
callback(new PluginError(PLUGIN_NAME, err))
if (file.isStream()) {
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'))
}

;(async () => {
try {
const newFile = await processHtml(file, options)
callback(null, newFile)
} catch (err) {
callback(new PluginError(PLUGIN_NAME, err))
}
})()
})
}

Expand Down

0 comments on commit 98523d2

Please sign in to comment.