mirror of https://github.com/curbengh/hexo-yam
chore: requires at least Node 10.18
BREAKING CHANGE: Drop Node 8 and iltorb - utilize native brotli - Drop string-to-buffer conversion * conversion was necessary for iltorb
This commit is contained in:
parent
48868bfa7e
commit
f0b37aaf45
|
@ -7,7 +7,7 @@ const Svgo = require('svgo')
|
||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
const { promisify } = require('util')
|
const { promisify } = require('util')
|
||||||
const gzip = promisify(zlib.gzip)
|
const gzip = promisify(zlib.gzip)
|
||||||
const br = require('zlib').brotliCompress ? promisify(require('zlib').brotliCompress) : require('iltorb').compress
|
const br = promisify(zlib.brotliCompress)
|
||||||
const micromatch = require('micromatch')
|
const micromatch = require('micromatch')
|
||||||
|
|
||||||
const isMatch = (path = '', patterns = [], options = {}) => {
|
const isMatch = (path = '', patterns = [], options = {}) => {
|
||||||
|
@ -151,10 +151,8 @@ function gzipFn () {
|
||||||
assetPath.on('end', async () => {
|
assetPath.on('end', async () => {
|
||||||
if (assetTxt.length) {
|
if (assetTxt.length) {
|
||||||
try {
|
try {
|
||||||
// TODO: Drop Buffer
|
const result = await gzip(assetTxt, { level })
|
||||||
const input = Buffer.from(assetTxt, 'utf-8')
|
if (options.logger) verbose.call(this, assetTxt, result, path, 'gzip')
|
||||||
const result = await gzip(input, { level })
|
|
||||||
if (options.logger) verbose.call(this, input, result, path, 'gzip')
|
|
||||||
resolve(route.set(path + '.gz', result))
|
resolve(route.set(path + '.gz', result))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(new Error(err))
|
reject(new Error(err))
|
||||||
|
@ -188,9 +186,8 @@ function brotliFn () {
|
||||||
assetPath.on('end', async () => {
|
assetPath.on('end', async () => {
|
||||||
if (assetTxt.length) {
|
if (assetTxt.length) {
|
||||||
try {
|
try {
|
||||||
const input = Buffer.from(assetTxt, 'utf-8')
|
const result = await br(assetTxt, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } })
|
||||||
const result = await br(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } })
|
if (options.logger) verbose.call(this, assetTxt, result, path, 'brotli')
|
||||||
if (options.logger) verbose.call(this, input, result, path, 'brotli')
|
|
||||||
resolve(route.set(path + '.br', result))
|
resolve(route.set(path + '.br', result))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(new Error(err))
|
reject(new Error(err))
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"test": "jest test/filter.test.js"
|
"test": "jest test/filter.test.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8.6.0"
|
"node": ">= 10.18.0"
|
||||||
},
|
},
|
||||||
"author": "curben",
|
"author": "curben",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -25,7 +25,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clean-css": "^4.2.1",
|
"clean-css": "^4.2.1",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"iltorb": "^2.4.2",
|
|
||||||
"micromatch": "^4.0.2",
|
"micromatch": "^4.0.2",
|
||||||
"svgo": "^1.2.2",
|
"svgo": "^1.2.2",
|
||||||
"terser": "^4.0.0"
|
"terser": "^4.0.0"
|
||||||
|
|
Loading…
Reference in New Issue