Skip to content

Conversation

@Yaman-kumarsahu
Copy link

@Yaman-kumarsahu Yaman-kumarsahu commented Oct 12, 2025

closes #360
Grouping keys before : and sorting the keys and the items in the group of the respective keys and then flattening the array.

Comment on lines +233 to +234
'test:a': 'foo',
'test:b': 'bar',
Copy link
Collaborator

@fisker fisker Oct 12, 2025

Choose a reason for hiding this comment

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

Can we also test scripts contains mutiple :s? Eg: test:a:a, test:a:b

Copy link
Author

Choose a reason for hiding this comment

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

Sure,
I have now added the test for this scenario.

Comment on lines +253 to +254
'test:a:a': 'foofoo',
'test:a:b': 'foobar',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'test:a:a': 'foofoo',
'test:a:b': 'foobar',
'test:a:a': 'foofoo',
'test:a:b': 'foobar',
'test:a-coverage': 'foobar',

Copy link
Author

Choose a reason for hiding this comment

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

Is the expected sorted file like this

'test:a',
'test:a-coverage',
'test:a:a',
'test:a:b',

or this

'test:a',
'test:a:a',
'test:a:b',
'test:a-coverage',

Copy link
Author

@Yaman-kumarsahu Yaman-kumarsahu Oct 13, 2025

Choose a reason for hiding this comment

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

If we want the sorting to be like this

'test:a',
'test:a:a',
'test:a:b',
'test:a-coverage',

we can replace the entire logic with

source = keys.slice().sort((a, b) => 
      a.replace(/:/g, ' ')
      .localeCompare(b.replace(/:/g, ' '), 'en'));

else the current code will sort it in this way

'test:a',
'test:a-coverage',
'test:a:a',
'test:a:b',

Co-authored-by: fisker Cheung <[email protected]>
}
source = Array.from(groupMap.keys())
.sort()
.flatMap((groupKey) => groupMap.get(groupKey).sort())
Copy link
Collaborator

@fisker fisker Oct 12, 2025

Choose a reason for hiding this comment

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

I think this should do recursively

Copy link
Author

@Yaman-kumarsahu Yaman-kumarsahu Oct 12, 2025

Choose a reason for hiding this comment

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

I don't think I am following. Could you tell me why?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The "group" can be deep

test
test:a
test:b
test-coverage

test:production
test:production:a
test:production:b
test:production-coverage

test:production:cjs
test:production:cjs:a
test:production:cjs:b
test:production:cjs-coverage

test:production:mjs
test:production:mjs:a
test:production:mjs:b
test:production:mjs-coverage

Copy link
Collaborator

@fisker fisker Oct 13, 2025

Choose a reason for hiding this comment

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

Also, current implementation seems relay on - and : order in ascii, it shouldn't

test
test:a
test:b
test[NO MATTER WHAT IS] # this should still put after the ones with `:`

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.

Improve scripts sorting

2 participants