Skip to content

Commit 2079dd5

Browse files
committed
run prettier at the end of generating js/arena-config.js
1 parent 6a73d50 commit 2079dd5

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

scripts/generate-arena-configs.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
const fs = require('fs');
1616
const path = require('path');
17+
const { execSync } = require('child_process');
1718

1819
// Simple YAML parser for our arena config format
1920
function parseYAML(yamlText) {
@@ -257,6 +258,17 @@ function getConfigsByGeneration() {
257258
if (typeof module !== 'undefined' && module.exports) {
258259
module.exports = { STANDARD_CONFIGS, PANEL_SPECS, getConfig, getConfigsByGeneration };
259260
}
261+
262+
// Browser global export (for non-module scripts)
263+
if (typeof window !== 'undefined') {
264+
window.STANDARD_CONFIGS = STANDARD_CONFIGS;
265+
window.PANEL_SPECS = PANEL_SPECS;
266+
window.getConfig = getConfig;
267+
window.getConfigsByGeneration = getConfigsByGeneration;
268+
}
269+
270+
// ES6 module export
271+
export { STANDARD_CONFIGS, PANEL_SPECS, getConfig, getConfigsByGeneration };
260272
`;
261273

262274
// Ensure js/ directory exists
@@ -266,7 +278,17 @@ if (typeof module !== 'undefined' && module.exports) {
266278
}
267279

268280
fs.writeFileSync(outputFile, output);
269-
console.log(`\nGenerated ${outputFile} with ${Object.keys(sortedConfigs).length} configs`);
281+
282+
// Format with Prettier to match project style
283+
try {
284+
execSync(`npx prettier --write "${outputFile}"`, { stdio: 'inherit' });
285+
console.log(
286+
`\nGenerated and formatted ${outputFile} with ${Object.keys(sortedConfigs).length} configs`
287+
);
288+
} catch (err) {
289+
console.log(`\nGenerated ${outputFile} with ${Object.keys(sortedConfigs).length} configs`);
290+
console.log('Warning: Could not run Prettier. Run "npm run format" to format the output.');
291+
}
270292
}
271293

272294
main();

0 commit comments

Comments
 (0)