Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Upgrade broccoli-persistent-filter to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
nlfurniss committed Sep 17, 2020
1 parent b303765 commit 5de8a43
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
language: node_js
node_js:
- '8'
- '6'
- '10'
46 changes: 23 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": {
Expand Down

0 comments on commit 5de8a43

Please sign in to comment.