From 66224418224e64c5494ebfe91f296ad7e16ecdf8 Mon Sep 17 00:00:00 2001 From: hustcer Date: Wed, 26 Jun 2024 21:32:24 +0800 Subject: [PATCH] fix: Fix plugin add for Nu after v0.93.0 --- .github/workflows/full-matrix.yaml | 2 +- .github/workflows/latest-matrix.yaml | 2 +- .github/workflows/release-matrix.yaml | 2 +- nu/register-plugins.nu | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/full-matrix.yaml b/.github/workflows/full-matrix.yaml index 075a0a0..7d21479 100644 --- a/.github/workflows/full-matrix.yaml +++ b/.github/workflows/full-matrix.yaml @@ -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}}) diff --git a/.github/workflows/latest-matrix.yaml b/.github/workflows/latest-matrix.yaml index b50073f..697bda7 100644 --- a/.github/workflows/latest-matrix.yaml +++ b/.github/workflows/latest-matrix.yaml @@ -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}}) diff --git a/.github/workflows/release-matrix.yaml b/.github/workflows/release-matrix.yaml index fa28215..d6fb2e0 100644 --- a/.github/workflows/release-matrix.yaml +++ b/.github/workflows/release-matrix.yaml @@ -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}}) diff --git a/nu/register-plugins.nu b/nu/register-plugins.nu index 520cf98..850eac6 100755 --- a/nu/register-plugins.nu +++ b/nu/register-plugins.nu @@ -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 @@ -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)' + } } }