Skip to content

Commit

Permalink
Fail dist build when for postcss warnings (#2180)
Browse files Browse the repository at this point in the history
* Fail dist build when for postcss warnings

* Create rotten-phones-ring.md

Co-authored-by: Jon Rohan <yes@jonrohan.codes>
  • Loading branch information
dgreif and jonrohan authored Jul 29, 2022
1 parent 370c8a2 commit c71e7df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-phones-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/css": patch
---

Fail dist build when for postcss warnings
9 changes: 9 additions & 0 deletions script/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ async function dist() {
const scss = await readFile(from, encoding)
meta.imports = getExternalImports(scss, path).map(getPathName)
const result = await compiler(scss, {from, to})
const warnings = result.warnings()

// We don't want to release changes that cause warnings with postcss. Fail the dist build if any warnings are detected.
if (warnings.length) {
for (const warning of warnings) {
console.warn(warning.toString())
}
throw new Error(`Warnings while compiling ${from}. See output above.`)
}

await Promise.all([
writeFile(to, result.css, encoding),
Expand Down

0 comments on commit c71e7df

Please sign in to comment.