From c71e7df03b9f6816dd2ce7f3d343f92edbc8cf00 Mon Sep 17 00:00:00 2001 From: Dusty Greif Date: Fri, 29 Jul 2022 13:26:30 -0700 Subject: [PATCH] Fail dist build when for postcss warnings (#2180) * Fail dist build when for postcss warnings * Create rotten-phones-ring.md Co-authored-by: Jon Rohan --- .changeset/rotten-phones-ring.md | 5 +++++ script/dist.js | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/rotten-phones-ring.md diff --git a/.changeset/rotten-phones-ring.md b/.changeset/rotten-phones-ring.md new file mode 100644 index 00000000..ac66efda --- /dev/null +++ b/.changeset/rotten-phones-ring.md @@ -0,0 +1,5 @@ +--- +"@primer/css": patch +--- + +Fail dist build when for postcss warnings diff --git a/script/dist.js b/script/dist.js index 17e2d58d..abc3b6c1 100755 --- a/script/dist.js +++ b/script/dist.js @@ -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),