From 996cb83aa20b04310dc1a77444165523bf2df616 Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Wed, 25 Sep 2019 00:10:57 +0100 Subject: [PATCH] refactor(cssFilter): async/await --- scripts/cssFilter.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/cssFilter.js b/scripts/cssFilter.js index 0151a02..9eefaff 100644 --- a/scripts/cssFilter.js +++ b/scripts/cssFilter.js @@ -13,19 +13,11 @@ const autoprefixer = require('autoprefixer') const normalize = require('postcss-normalize') const postcss = require('postcss') -hexo.extend.renderer.register('css', 'css', (data, options) => { +hexo.extend.renderer.register('css', 'css', async (data) => { if (data.path) { if (data.path.endsWith('.min.css')) return data.text } - return new Promise((resolve, reject) => { - postcss([normalize, autoprefixer]) - .process(data.text, { from: data.path }) - .then(result => { - resolve(result.css) - }, - error => { - reject(error) - }) - }) + const result = await postcss([normalize, autoprefixer]).process(data.text, { from: data.path }) + return result.css })