Skip to content

Commit

Permalink
fix: Fix plugin add for Nu after v0.93.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Jun 26, 2024
1 parent fec554d commit 6622441
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/full-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-22.04, macos-latest]
ver: [0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.89.0, 0.88.1, 0.87.1, 0.86]
ver: [0.95.0, 0.94.2, 0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.89.0, 0.88.1, 0.87.1, 0.86]

runs-on: ${{ matrix.os }}
name: test (${{matrix.os}}, nu@${{matrix.ver}})
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-22.04, macos-latest]
ver: [0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.88.1, 0.87.1, 0.86, 0.85, 0.83.1, 0.82, '0.80', 0.79, 0.78, 0.77.1, 0.75, 0.73, 0.72.1]
ver: [0.95.0, 0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.88.1, 0.87.1, 0.86, 0.85, 0.83.1, 0.82, '0.80', 0.79, 0.78, 0.77.1, 0.75, 0.73, 0.72.1]

runs-on: ${{ matrix.os }}
name: test (${{matrix.os}}, nu@${{matrix.ver}})
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-22.04, macos-latest]
ver: [0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.88.1, 0.87.1, 0.86, 0.85, 0.83.1, '0.80', 0.79, 0.78, 0.77.1, 0.75, 0.73, 0.72.1]
ver: [0.95.0, 0.93.0, 0.92.2, 0.91.0, 0.90.1, 0.88.1, 0.87.1, 0.86, 0.85, 0.83.1, '0.80', 0.79, 0.78, 0.77.1, 0.75, 0.73, 0.72.1]

runs-on: ${{ matrix.os }}
name: test (${{matrix.os}}, nu@${{matrix.ver}})
Expand Down
9 changes: 8 additions & 1 deletion nu/register-plugins.nu
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
# Config files are needed to avoid plugin register failure.
# The following lines were used to fix `× Plugin failed to load: No such file or directory (os error 2)`

use common.nu [is-lower-ver]

def main [
version: string, # The tag name or version of the release to use.
] {

let name = if $version =~ 'nightly' { 'nightly' } else { 'nushell' }
let useRegister = if $version =~ 'nightly' or $version == '*' or (is-lower-ver 0.93.0 $version) { false } else { true }
let config_path = ($nu.env-path | path dirname)
let config_prefix = $'https://github.com/nushell/($name)/blob/($version)/crates/nu-utils/src'
aria2c $'($config_prefix)/sample_config/default_env.nu' -o env.nu -d $config_path
Expand All @@ -22,7 +25,11 @@ def main [
| where name =~ nu_plugin
| each {|plugin|
print $'Registering ($plugin.name)'
nu -c $'register ($plugin.name)'
if $useRegister {
nu -c $'register ($plugin.name)'
} else {
nu -c $'plugin add ($plugin.name)'
}
}
}

Expand Down

0 comments on commit 6622441

Please sign in to comment.