mirror of https://github.com/curbengh/hexo-yam
refactor: destructure
This commit is contained in:
parent
ce8c4a145b
commit
37ba1d9a2b
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const Htmlminifier = require('html-minifier').minify
|
const { minify: htmlMinify } = require('html-minifier')
|
||||||
const CleanCSS = require('clean-css')
|
const CleanCSS = require('clean-css')
|
||||||
const { minify: terserMinify } = require('terser')
|
const { minify: terserMinify } = require('terser')
|
||||||
const Svgo = require('svgo')
|
const Svgo = require('svgo')
|
||||||
|
@ -71,7 +71,7 @@ function minifyHtml (str, data) {
|
||||||
if (isMatch(path, exclude, globOptions)) return str
|
if (isMatch(path, exclude, globOptions)) return str
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = Htmlminifier(str, options)
|
const result = htmlMinify(str, options)
|
||||||
if (verbose) logFn.call(this, str, result, path, 'html')
|
if (verbose) logFn.call(this, str, result, path, 'html')
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const Hexo = require('hexo')
|
const Hexo = require('hexo')
|
||||||
const Htmlminifier = require('html-minifier').minify
|
const { minify: htmlMinify } = require('html-minifier')
|
||||||
|
|
||||||
describe('html', () => {
|
describe('html', () => {
|
||||||
const hexo = new Hexo(__dirname)
|
const hexo = new Hexo(__dirname)
|
||||||
|
@ -26,7 +26,7 @@ describe('html', () => {
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const expected = Htmlminifier(input, defaultCfg.html)
|
const expected = htmlMinify(input, defaultCfg.html)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
hexo.config.minify = JSON.parse(JSON.stringify(defaultCfg))
|
hexo.config.minify = JSON.parse(JSON.stringify(defaultCfg))
|
||||||
|
@ -57,7 +57,7 @@ describe('html', () => {
|
||||||
hexo.config.minify.html = customOpt
|
hexo.config.minify.html = customOpt
|
||||||
|
|
||||||
const result = h(input, { path })
|
const result = h(input, { path })
|
||||||
const expected = Htmlminifier(input, customOpt)
|
const expected = htmlMinify(input, customOpt)
|
||||||
|
|
||||||
expect(result).toBe(input)
|
expect(result).toBe(input)
|
||||||
expect(result).toBe(expected)
|
expect(result).toBe(expected)
|
||||||
|
|
Loading…
Reference in New Issue