fix: join Array, instead of using first index

This commit is contained in:
curbengh 2019-10-06 09:24:25 +01:00
parent 461fe1dd41
commit 48bf9951f0
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 5 additions and 4 deletions

View File

@ -121,8 +121,8 @@ function minifySvg () {
assetPath.on('end', async () => {
if (assetTxt.length) {
try {
const result = await new Svgo(options).optimize(assetTxt)
if (options.logger) verbose.call(this, assetTxt.toString(), result.data, path, 'svg')
const result = await new Svgo(options).optimize(assetTxt.join())
if (options.logger) verbose.call(this, assetTxt.join().toString(), result.data, path, 'svg')
resolve(route.set(path, result.data))
} catch (err) {
error.call(this, err)
@ -155,7 +155,8 @@ function gzipFn () {
assetPath.on('end', async () => {
if (assetTxt.length) {
try {
const input = Buffer.from(assetTxt[0], 'utf-8')
// TODO: Drop Buffer
const input = Buffer.from(assetTxt.join(), 'utf-8')
const result = await gzip(input, { level: zlib.constants.Z_BEST_COMPRESSION })
if (options.logger) verbose.call(this, input, result.toString(), path, 'gzip')
resolve(route.set(path + '.gz', result))
@ -190,7 +191,7 @@ function brotliFn () {
assetPath.on('end', async () => {
if (assetTxt.length) {
try {
const input = Buffer.from(assetTxt[0], 'utf-8')
const input = Buffer.from(assetTxt.join(), 'utf-8')
const result = await br(input)
if (options.logger) verbose.call(this, input, result.toString(), path, 'brotli')
resolve(route.set(path + '.br', result))