diff --git a/packages/components/package.json b/packages/components/package.json index a8ba947163b..32cc3a1cf06 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -30,7 +30,8 @@ "lint:js:fix": "eslint . --fix", "lint:types": "glint", "start": "rollup --config --watch --environment development", - "prepublishOnly": "pnpm build && test -f 'dist/styles/@hashicorp/design-system-components.css' || (echo \"\n\\033[31m⚠️ Error: the pre-compiled CSS file \\`dist/styles/@hashicorp/design-system-components.css\\` was not found\\033[0m\\n\" && exit 1)" + "test:dist-files": "node scripts/check-dist-files.mjs", + "prepublishOnly": "pnpm build && pnpm test:dist-files" }, "dependencies": { "@codemirror/autocomplete": "^6.20.0", diff --git a/packages/components/scripts/check-dist-files.mjs b/packages/components/scripts/check-dist-files.mjs new file mode 100644 index 00000000000..b2f8c1eedc6 --- /dev/null +++ b/packages/components/scripts/check-dist-files.mjs @@ -0,0 +1,23 @@ +#!/usr/bin/env node + +import { existsSync } from 'node:fs'; + +const FILES_TO_CHECK = [ + 'dist/styles/@hashicorp/design-system-components.css', + 'dist/styles/@hashicorp/design-system-power-select-overrides.css', +]; + +let hasErrors = false; + +for (const file of FILES_TO_CHECK) { + if (!existsSync(file)) { + console.error( + `\n\x1b[31m⚠️ Error: the pre-compiled CSS file \`${file}\` was not found\x1b[0m\n` + ); + hasErrors = true; + } +} + +if (hasErrors) { + process.exit(1); +}