refactor: destructure

This commit is contained in:
MDLeom 2020-09-05 11:22:36 +00:00
parent ce8c4a145b
commit 37ba1d9a2b
No known key found for this signature in database
GPG Key ID: 06C236E63CBC68AA
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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)