Conversation
WalkthroughThe updates replace all usages of shell-based methods for locating the Nu executable's directory (using Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow/Script
participant NuShell
Workflow/Script->>NuShell: Request $nu.current-exe
NuShell-->>Workflow/Script: Return path to current Nu executable
Workflow/Script->>NuShell: Use path dirname to locate directory
Workflow/Script->>NuShell: List directory contents or register plugins
sequenceDiagram
participant Script
participant Plugins List
Script->>Plugins List: Iterate plugins with reduce
Plugins List-->>Script: For each plugin, check if enabled
Script->>Plugins List: Accumulate matching plugins
Script-->>Script: Use accumulated plugin list
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Based on the provided code changes, I'll analyze the frontend-related aspects of the GitHub Actions workflows and Nu shell scripts: Code Analysis
Security Review
Optimization Suggestions
Overall Quality: 4 The changes show good attention to:
One point deducted because the changes could benefit from:
|
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes Nu setup by switching to the new $nu.current-exe API, refactors plugin filtering to support executables with extensions, and removes an outdated script.
- Replace
which nulookups with$nu.current-exefor path discovery - Refactor plugin filtering from
filtertoreduceto handle.exeextensions - Remove the obsolete
nu/prepare.nuscript - Update documentation and CI workflows to use the new path resolution
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugins.ts | Use $nu.current-exe and refactor plugin filtering with reduce |
| nu/register-plugins.nu | Mirror path lookup and filtering changes in the registration flow |
| nu/prepare.nu | Entirely removed obsolete setup script |
| README.md & README.zh-CN.md | Update examples to use $nu.current-exe for directory listing |
| Justfile | Update NU_DIR to derive from $nu.current-exe |
| .github/workflows/*.yaml | Adjust CI steps to list directory contents via $nu.current-exe |
Comments suppressed due to low confidence (3)
src/plugins.ts:44
- [nitpick] The comment could be expanded to explain why splitting on '.' is safe for all plugin filenames and how it handles names with multiple dots.
# "split row . | first" used to handle binary with .exe extension
src/plugins.ts:43
- The new filtering logic, especially handling
.exeextensions, should have dedicated unit tests to verify correct behavior across different plugin name patterns.
$allPlugins | reduce -f [] {|it, acc|
| $allPlugins | reduce -f [] {|it, acc| | ||
| # "split row . | first" used to handle binary with .exe extension | ||
| if $enablePlugins =~ ($it.name | path basename | split row . | first) { | ||
| $acc | append $it | ||
| } else { | ||
| $acc | ||
| } | ||
| } |
There was a problem hiding this comment.
[nitpick] The reduce-based plugin filtering logic is duplicated in both plugins.ts and register-plugins.nu; consider extracting this into a shared helper to avoid duplication and improve maintainability.
| $allPlugins | reduce -f [] {|it, acc| | |
| # "split row . | first" used to handle binary with .exe extension | |
| if $enablePlugins =~ ($it.name | path basename | split row . | first) { | |
| $acc | append $it | |
| } else { | |
| $acc | |
| } | |
| } | |
| filterPlugins($allPlugins, $enablePlugins) |
| $allPlugins | ||
| } else { | ||
| $allPlugins | filter {|it| $enablePlugins =~ ($it.name | path basename | split row . | first)} | ||
| $allPlugins | reduce -f [] {|it, acc| |
There was a problem hiding this comment.
[nitpick] Similar plugin filtering logic is duplicated here; consider consolidating this into a single reusable function to reduce code duplication.
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
.github/workflows/full-matrix.yaml (1)
43-46: Guard$nu.current-exeusage for Nushell < 0.101.0
$nu.current-exewas only introduced in Nushell 0.101.0 (released Dec 24, 2024)1, so referencing it in older versions (e.g. 0.86) will cause the step to fail at runtime.Suggested fixes:
- Restrict the test matrix to Nushell >= 0.101.0.
- Or provide a fallback for older releases, e.g. use
which nuwhen$nu.current-exeis undefined.Location:
- .github/workflows/full-matrix.yaml: lines 43–46
🧹 Nitpick comments (6)
src/plugins.ts (1)
43-50: Consider reverting to the simplerfilterapproach.The change from
filtertoreducemakes the code more verbose without providing additional benefits. The originalfilterapproach was more concise and readable:- $allPlugins | reduce -f [] {|it, acc| - # "split row . | first" used to handle binary with .exe extension - if $enablePlugins =~ ($it.name | path basename | split row . | first) { - $acc | append $it - } else { - $acc - } - } + $allPlugins | filter {|it| + # "split row . | first" used to handle binary with .exe extension + $enablePlugins =~ ($it.name | path basename | split row . | first) + }README.zh-CN.md (1)
51-52: Great simplification, but keep examples consistent.Switching from
((which nu).path.0 | path dirname)to($nu.current-exe | path dirname)removes the array‐indexing hack – nice.
However, earlier in the same README we still print the path with(which nu). Consider updating the remaining occurrences so newcomers don’t wonder why two different idioms are used.- print $'Nu path:(which nu)(char nl)' + print $'Nu path:($nu.current-exe)(char nl)'.github/workflows/basic.yaml (1)
55-59: Update the matching “Nu path” print for coherenceNow that directory discovery relies on
$nu.current-exe, printing the binary path viawhich nufeels uneven. Unless you purposely want to demo both ways, align them:- print $'Nu path:(which nu)(char nl)' + print $'Nu path:($nu.current-exe)(char nl)'README.md (1)
55-56: Keep documentation consistent across languagesSame inconsistency here as in the Chinese README: we switched the ls example but left the “Nu path” line untouched. Recommend updating for uniformity (see diff below).
- print $'Nu path:(which nu)(char nl)' + print $'Nu path:($nu.current-exe)(char nl)'.github/workflows/main-matrix.yaml (1)
38-41: Same consistency & compatibility notes as above
- Consider changing the preceding “Show Nu Binary Path” step to use
$nu.current-exefor symmetry.- Confirm
$nu.current-exeexists for all versions in this matrix, otherwise gate the dir-listing step with a version check.- run: print $'Nu path:(which nu)(char nl)' + run: print $'Nu path:($nu.current-exe)(char nl)'nu/register-plugins.nu (1)
36-43: Consider reverting to the more idiomaticfilterapproach.The change from
filtertoreduceadds unnecessary complexity without functional benefit. The originalfilterapproach would be cleaner and more idiomatic:- $allPlugins | reduce -f [] {|it, acc| - # "split row . | first" used to handle binary with .exe extension - if $enablePlugins =~ ($it.name | path basename | split row . | first) { - $acc | append $it - } else { - $acc - } - } + $allPlugins | filter {|it| + # "split row . | first" used to handle binary with .exe extension + $enablePlugins =~ ($it.name | path basename | split row . | first) + }The
filterapproach is more concise, readable, and semantically appropriate for this use case.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
dist/index.jsis excluded by!**/dist/**
📒 Files selected for processing (13)
.github/workflows/basic.yaml(2 hunks).github/workflows/build.yaml(1 hunks).github/workflows/full-matrix.yaml(1 hunks).github/workflows/latest-matrix.yaml(1 hunks).github/workflows/main-matrix.yaml(1 hunks).github/workflows/release-matrix.yaml(1 hunks).github/workflows/use-nightly.yaml(1 hunks)Justfile(1 hunks)README.md(1 hunks)README.zh-CN.md(1 hunks)nu/prepare.nu(0 hunks)nu/register-plugins.nu(2 hunks)src/plugins.ts(2 hunks)
💤 Files with no reviewable changes (1)
- nu/prepare.nu
🔇 Additional comments (10)
src/plugins.ts (2)
24-24: Good improvement: Using internal Nu variable instead of external command.Replacing
which nuwith$nu.current-exeis a more reliable approach as it:
- Eliminates dependency on external shell commands
- Uses Nu's internal variable which is guaranteed to be available
- Avoids potential PATH resolution issues
28-28: Consistent debug output update.The debug output change aligns with the switch to
$nu.current-exe, providing consistent information about the executable path..github/workflows/release-matrix.yaml (1)
39-39: Consistent improvement: Using Nu's internal executable variable.The change from
(which nu).path.0 | path dirnameto$nu.current-exe | path dirnameis consistent with the overall refactoring effort and provides better reliability by using Nu's internal variable instead of external shell command lookups..github/workflows/latest-matrix.yaml (1)
40-40: Consistent with the refactoring effort.The change to use
$nu.current-exe | path dirnamealigns with the project-wide effort to replace external shell command lookups with Nu's internal variables, improving reliability and consistency..github/workflows/build.yaml (1)
51-51: Consistent refactoring improvement.The change maintains consistency with the project-wide refactoring to use Nu's internal
$nu.current-exevariable instead of external shell command lookups, which is more reliable and future-proof..github/workflows/use-nightly.yaml (1)
51-51: Completes the consistent refactoring across workflow files.This change aligns with the updates made across all other workflow files, ensuring a unified approach to determining the Nu executable directory using Nu's internal variable instead of external shell commands.
.github/workflows/basic.yaml (1)
24-25: 👍 Cleaner dir-lookupThe switch to
$nu.current-exeavoids the brittlewhich … | get 0. Looks good.Justfile (1)
31-31: LGTM! Good modernization for future Nu compatibility.The change from
(which nu).path.0to$nu.current-exeis a solid improvement that:
- Uses Nu's built-in variable instead of external shell command
- Improves reliability and future compatibility
- Aligns with the PR objective to update Nu for future versions
nu/register-plugins.nu (2)
17-17: LGTM! Modernized executable path resolution.The change from
(which nu | get 0.path | path dirname)to$nu.current-exe | path dirnameimproves future compatibility by using Nu's built-in variable instead of external shell commands.
21-21: LGTM! Consistent debug output update.The debug output correctly reflects the new approach using
$nu.current-exe.
feat: Update setup Nu for future versions of Nu
Summary by CodeRabbit
Refactor
Documentation