Skip to content

Commit

Permalink
fix: Fix register of all plugins with enablePlugins: true input
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Jun 29, 2024
1 parent d078370 commit 1a2c1cd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.

- Fix release script of pushing release Tags
- Fix plugin register related issue for all platforms
- Fix register of all plugins with `enablePlugins: true` input

### Features

Expand Down
14 changes: 10 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion nu/register-plugins.nu
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def main [

let useRegister = if $is_legacy { true } else { false }
let nuDir = (which nu | get 0.path | path dirname)
print $'enablePlugins: ($enablePlugins) of Nu version: ($version)'

print 'Output of (which nu):'
print (which nu)
Expand All @@ -28,10 +29,15 @@ def main [
# print (ls $nu.default-config-dir)

let allPlugins = ls $nuDir | where name =~ nu_plugin
let filteredPlugins = if $enablePlugins == 'true' { $allPlugins } else {
let filteredPlugins = if $enablePlugins == "'true'" or $enablePlugins == 'true' {
$allPlugins
} else {
$allPlugins | filter {|it| $enablePlugins =~ ($it.name | path basename | split row . | first)}
}

print $'Filtered plugins:'
print $filteredPlugins

$filteredPlugins | each {|plugin|
let p = $plugin.name | str replace -a \ /
if $useRegister {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins-tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export async function registerPlugins(enablePlugins: string, version: string) {
} else {
shell.exec(`nu ${script} "'${enablePlugins}'" ${version}`);
}
console.log('Contents of `do-register.nu`:\n');
const content = shell.cat('do-register.nu');
console.log(content.toString());
// console.log('Contents of `do-register.nu`:\n');
// const content = shell.cat('do-register.nu');
// console.log(content.toString());
console.log('\nRegistering plugins...\n');
shell.exec('nu do-register.nu');
console.log(`Plugins registered successfully for Nu ${version}.`);
Expand Down
14 changes: 10 additions & 4 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def main [
let useRegister = if $is_legacy { true } else { false }
let nuDir = (which nu | get 0.path | path dirname)
print $'enablePlugins: ($enablePlugins) of Nu version: ($version)'
print 'Output of (which nu):'
print (which nu)
Expand All @@ -35,10 +36,15 @@ def main [
# print (ls $nu.default-config-dir)
let allPlugins = ls $nuDir | where name =~ nu_plugin
let filteredPlugins = if $enablePlugins == 'true' { $allPlugins } else {
let filteredPlugins = if $enablePlugins == "'true'" or $enablePlugins == 'true' {
$allPlugins
} else {
$allPlugins | filter {|it| $enablePlugins =~ ($it.name | path basename | split row . | first)}
}
print $'Filtered plugins:'
print $filteredPlugins
$filteredPlugins | each {|plugin|
let p = $plugin.name | str replace -a \ /
if $useRegister {
Expand Down Expand Up @@ -71,9 +77,9 @@ export async function registerPlugins(enablePlugins: string, version: string) {
} else {
shell.exec(`nu ${script} "'${enablePlugins}'" ${version}`);
}
console.log('Contents of `do-register.nu`:\n');
const content = shell.cat('do-register.nu');
console.log(content.toString());
// console.log('Contents of `do-register.nu`:\n');
// const content = shell.cat('do-register.nu');
// console.log(content.toString());
console.log('\nRegistering plugins...\n');
shell.exec('nu do-register.nu');
console.log(`Plugins registered successfully for Nu ${version}.`);
Expand Down

0 comments on commit 1a2c1cd

Please sign in to comment.