-
Notifications
You must be signed in to change notification settings - Fork 99
fix: improve-scripts-sorting #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: improve-scripts-sorting #376
Conversation
| 'test:a': 'foo', | ||
| 'test:b': 'bar', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| 'test:a:a': 'foofoo', | ||
| 'test:a:b': 'foobar', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'test:a:a': 'foofoo', | |
| 'test:a:b': 'foobar', | |
| 'test:a:a': 'foofoo', | |
| 'test:a:b': 'foobar', | |
| 'test:a-coverage': 'foobar', |
There was a problem hiding this comment.
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',There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 `:`
closes #360
Grouping keys before : and sorting the keys and the items in the group of the respective keys and then flattening the array.