| 4 | const postcss = require('postcss'); |
| 5 | |
| 6 | const duplicateVariablesDifferentValues = async () => { |
| 7 | const files = await globby([ |
| 8 | 'packages/gestalt/src/**/*.css', |
| 9 | 'packages/gestalt-charts/src/**/*.css', |
| 10 | 'packages/gestalt-datepicker/src/**/*.css', |
| 11 | ]); |
| 12 | |
| 13 | const combined = ( |
| 14 | await Promise.all(files.map(async (file) => await fs.promises.readFile(file, 'utf8'))) |
| 15 | ).join(''); |
| 16 | |
| 17 | const astRoot = postcss.parse(combined); |
| 18 | |
| 19 | const lookup = {}; |
| 20 | astRoot.walkDecls(/^--g/, ({ prop, value }) => { |
| 21 | if (lookup[prop] && lookup[prop] !== value) { |
| 22 | throw new Error( |
| 23 | `CSS Validate error: ${prop} is defined multiple times with different values: ${lookup[prop]} & ${value}.\nPlease make these the same`, |
| 24 | ); |
| 25 | } |
| 26 | lookup[prop] = value; |
| 27 | }); |
| 28 | }; |
| 29 | |
| 30 | (async function cssValidate() { |
| 31 | try { |