From e11d8852d1a760c6a926c7231236ccaf5b56649c Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Wed, 9 Sep 2020 14:31:10 -0700 Subject: [PATCH] Upgrade broccoli-persistent-filter to v3 --- .travis.yml | 3 +-- index.js | 46 +++++++++++++++++++++++----------------------- package.json | 6 +++--- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index e0cc348..d2442b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ language: node_js node_js: - - '8' - - '6' + - '10' diff --git a/index.js b/index.js index 8591214..5713f95 100644 --- a/index.js +++ b/index.js @@ -19,35 +19,35 @@ module.exports = class extends Filter { return 'css'; } - processString(text, relativePath) { - const options = Object.assign({ + async processString(text, relativePath) { + const options = { from: relativePath, - to: relativePath - }, this.options); + to: relativePath, + ...this.options + }; // Support explicit override of inline sourcemaps if (options.sourcemap !== null || options.sourcemap !== undefined) { options.map = options.sourcemap ? 'inline' : false; } - return postcss(autoprefixer(options)) - .process(text, options) - .then(result => { - const warnings = result.warnings(); - - if (warnings.length > 0) { - console.error(warnings.join('\n')); - } - - return result.css; - }) - .catch(error => { - if (error.name === 'CssSyntaxError') { - // TODO: Find a way to hide the stack so to adhere to the PostCSS guidelines - error.message += error.showSourceCode(); - } - - throw error; - }); + let result; + try { + result = await postcss(autoprefixer(options)).process(text, options); + } catch (error) { + if (error.name === 'CssSyntaxError') { + // TODO: Find a way to hide the stack so to adhere to the PostCSS guidelines + error.message += error.showSourceCode(); + } + throw error; + } + + const warnings = result.warnings(); + + if (warnings.length > 0) { + console.error(warnings.join('\n')); + } + + return result.css; } }; diff --git a/package.json b/package.json index 5ebcd8e..25934ea 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=10" }, "scripts": { "test": "xo && broccoli build temp && ava" @@ -31,7 +31,7 @@ ], "dependencies": { "autoprefixer": "^9.8.4", - "broccoli-persistent-filter": "^1.1.6", + "broccoli-persistent-filter": "^3.0.0", "postcss": "^7.0.2" }, "devDependencies": {