mirror of https://github.com/curbengh/hexo-yam
fix: utilize hexo.log to display error message
This commit is contained in:
parent
680ee73a03
commit
2c5ad19932
|
@ -24,6 +24,11 @@ function verbose (original, minified, path, ext) {
|
||||||
log.log(`${ext}: ${path} [${saved}% saved]`)
|
log.log(`${ext}: ${path} [${saved}% saved]`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function error (msg) {
|
||||||
|
const log = this.log || console
|
||||||
|
log.error(msg)
|
||||||
|
}
|
||||||
|
|
||||||
function minifyHtml (str, data) {
|
function minifyHtml (str, data) {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.minify.html
|
const options = hexo.config.minify.html
|
||||||
|
@ -64,7 +69,7 @@ async function minifyCss (str, data) {
|
||||||
if (options.logger) verbose.call(this, str, result.styles, path, 'css')
|
if (options.logger) verbose.call(this, str, result.styles, path, 'css')
|
||||||
return result.styles
|
return result.styles
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(err)
|
error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +127,8 @@ function minifySvg () {
|
||||||
if (options.logger) verbose.call(this, assetTxt, result.data, path, 'svg')
|
if (options.logger) verbose.call(this, assetTxt, result.data, path, 'svg')
|
||||||
resolve(route.set(path, result.data))
|
resolve(route.set(path, result.data))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
error(err)
|
||||||
reject(err)
|
reject(err)
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -159,8 +164,8 @@ function gzipFn () {
|
||||||
if (options.logger) verbose.call(this, assetTxt, result.toString(), path, 'gzip')
|
if (options.logger) verbose.call(this, assetTxt, result.toString(), path, 'gzip')
|
||||||
resolve(route.set(path + '.gz', result))
|
resolve(route.set(path + '.gz', result))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
error(err)
|
||||||
reject(err)
|
reject(err)
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -198,8 +203,8 @@ function brotliFn () {
|
||||||
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))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
error(err)
|
||||||
reject(err)
|
reject(err)
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue