Repository navigation
Add sorting to npm scripts - #112725
Merged
Alex Ross (alexr00) merged 4 commits intoDec 22, 2020
Merged
Add sorting to npm scripts#112725
Conversation
Contributor
Author
|
This PR also fixes (duplicates): Alex Ross (@alexr00) Johannes Rieken (@jrieken) Please let me know if this PR looks good or if you have any questions. I would like the fix to be available in the next release. Thanks! |
Ashok314
reviewed
Dec 20, 2020
Ashok314
left a comment
There was a problem hiding this comment.
I have added the comments for a test case where there is only one item.
|
stop this
…On 20 Dec 2020 11:13 a.m., "Bohdan Yevchenko" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In extensions/npm/src/npmView.ts
<#112725 (comment)>:
> @@ -276,7 +279,15 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
return fullName === task.name;
}
- private buildTaskTree(tasks: TaskWithLocation[]): Folder[] | PackageJSON[] | NoScripts[] {
+ private sortTaskTree(taskTree: TaskTree) {
+ return taskTree.sort((first, second) => {
+ const firstLabel = first.label?.toString() || '';
+ const secondLabel = second.label?.toString() || '';
+ return firstLabel.localeCompare(secondLabel);
The second item will always be provided to the comparator function.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#112725 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASEC3OZPUQ55XC3Q4KLWUCDSVWFHBANCNFSM4U7NKP3Q>
.
|
Contributor
Author
|
ami-eng not sure what do you want me to stop. You probably want to just click on the unsubscribe link instead to stop receiving the notifications. |
Ashok314
approved these changes
Dec 20, 2020
Alex Ross (alexr00)
requested changes
Dec 21, 2020
Alex Ross (alexr00)
approved these changes
Dec 22, 2020
Alex Ross (alexr00)
left a comment
Member
There was a problem hiding this comment.
Looks good, thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #92773 - npm scripts panel is not ordered
Our team has a pain point in npm scripts because we have a lot of package.json files inside our repo and the npm scripts are always different, so it's super difficult to find the one you are looking for.
Current implementation:

Observe the order is always different. Scripts are jumping.
Suggested approach:

Sort by the label. The order will remain the same. Easy to find the command you are looking for.