Skip to content

Commit

Permalink
fix: Fix config reset for setup-nu action
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Sep 12, 2023
1 parent 1392bd8 commit 727cf43
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/latest-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Setup nu@${{matrix.ver}}
uses: hustcer/setup-nu@main
with:
enable-plugins: true
version: ${{matrix.ver}}
env:
ACTIONS_STEP_DEBUG: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/module-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: Setup nu@latest
uses: hustcer/setup-nu@develop
with:
version: ${{matrix.ver}}
enable-plugins: true
version: ${{matrix.ver}}
env:
ACTIONS_STEP_DEBUG: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Setup nu@${{matrix.ver}}
uses: hustcer/[email protected]
with:
enable-plugins: true
version: ${{matrix.ver}}
env:
ACTIONS_STEP_DEBUG: true
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

34 changes: 21 additions & 13 deletions nu/register-plugins.nu
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@

# 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)`
let config_path = ($nu.env-path | path dirname)
let config_prefix = 'https://raw.githubusercontent.com/nushell/nushell/main/crates/nu-utils/src'
aria2c $'($config_prefix)/sample_config/default_config.nu' -o config.nu -d $config_path
config reset --without-backup

def register-plugins [] {
ls (which nu | get 0.path | path dirname)
| where name =~ nu_plugin
| each {|plugin|
print $'Registering ($plugin.name)'
nu -c $'register ($plugin.name)'
}
def main [
version: string, # The tag name or version of the release to use.
] {

let config_path = ($nu.env-path | path dirname)
let config_prefix = $'https://github.com/nushell/nushell/blob/($version)/crates/nu-utils/src'
aria2c $'($config_prefix)/sample_config/default_env.nu' -o env.nu -d $config_path
aria2c $'($config_prefix)/sample_config/default_config.nu' -o config.nu -d $config_path
# config reset --without-backup

def register-plugins [] {
ls (which nu | get 0.path | path dirname)
| where name =~ nu_plugin
| each {|plugin|
print $'Registering ($plugin.name)'
nu -c $'register ($plugin.name)'
}
}

register-plugins
print $'(char nl)Plugins registered successfully for Nu ($version).'
}

register-plugins
print $"(char nl)Plugins registered successfully"
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ async function main() {
versionSpec: ver,
});
core.addPath(tool.dir);
core.info('Reset NuShell config...');
shell.exec("nu -c 'config reset --without-backup'");
core.info(`Successfully setup ${tool.name} v${tool.version}`);

if (enablePlugins) {
console.log('Running ./nu/register-plugins.nu to register plugins...');
shell.exec('nu ./nu/register-plugins.nu');
shell.exec(`nu ./nu/register-plugins.nu ${tool.version}`);
}
} catch (err) {
core.setFailed(err.message);
Expand Down

0 comments on commit 727cf43

Please sign in to comment.