Skip to content

Conversation

osfameron
Copy link
Collaborator

Fix populate-icon-definitions by adding definitions to set rather than ever-expanding array.

This might not be the final version of work (as part of understanding and debugging the script, I changed it from async to sync... though on the other hand, it only takes < 10 seconds for the full Staging build, so it isn't unthinkable)

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the icon definitions script where icons were being accumulated into an ever-expanding array instead of a set, causing duplicate entries. The script has also been refactored from asynchronous to synchronous execution for debugging purposes.

  • Fix icon accumulation logic by using Set instead of array concatenation
  • Refactor from async/await to synchronous file operations
  • Improve code organization and documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// /*! iconNames: ['far fa-copy', 'fas fa-link', 'fab fa-github', 'fas fa-terminal', 'fal fa-external-link-alt'] */

let contents = fs.readFileSync(iconDefsFile, 'utf8')
let firstLine = contents.substr(0, contents.indexOf("\n"));
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use substring() instead of the deprecated substr() method. Replace with contents.substring(0, contents.indexOf('\n')).

Suggested change
let firstLine = contents.substr(0, contents.indexOf("\n"));
let firstLine = contents.substring(0, contents.indexOf("\n"));

Copilot uses AI. Check for mistakes.

if (contents.includes(ICON_SIGNATURE_CS)) {
return contents.toString()
.match(ICON_RX)
.map((it) => it.substr(10))
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use substring() instead of the deprecated substr() method. Replace with it.substring(10).

Suggested change
.map((it) => it.substr(10))
.map((it) => it.substring(10))

Copilot uses AI. Check for mistakes.


try {
const requiredIconNames = JSON.parse(firstLine.match(REQUIRED_ICON_NAMES_RX)[1].replace(/'/g, '"'))
console.log(requiredIconNames)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this debug console.log statement as it appears to be leftover from debugging and should not be in production code.

Suggested change
console.log(requiredIconNames)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant