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