fnva 0.0.45 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,9 +14,9 @@ Cross-platform environment switcher for Java, Claude Code (CC), and LLM setups.
14
14
 
15
15
  ## Quick start
16
16
 
17
- - Init shell (Bash/Zsh): `eval "$(fnva env --shell bash)"`
18
- PowerShell: `fnva env --shell powershell | Out-String | Invoke-Expression`
19
- Fish: `fnva env --shell fish | source`
17
+ - Init shell (Bash/Zsh): `eval "$(fnva env env --shell bash)"`
18
+ PowerShell: `fnva env env --shell powershell | Out-String | Invoke-Expression`
19
+ Fish: `fnva env env --shell fish | source`
20
20
  - Scan Java: `fnva java scan`
21
21
  - Switch Java for current session: `fnva java use jdk-17` (with shell integration)
22
22
  - Switch CC profile: `fnva cc use glmcc` (with shell integration)
package/bin/fnva.js CHANGED
@@ -501,6 +501,27 @@ function run() {
501
501
  }
502
502
  const isSwitchCommand = isEnvironmentSwitchCommand(args);
503
503
 
504
+ // Unix: 直接透传给 Rust 二进制,不拦截参数
505
+ // shell wrapper 函数负责捕获输出并 source
506
+ if (process.platform !== 'win32') {
507
+ const result = spawnSync(binaryPath, args, {
508
+ stdio: 'inherit',
509
+ });
510
+
511
+ if (result.error) {
512
+ if (result.error.code === 'EACCES') {
513
+ console.error(`[ERROR] Permission denied. The fnva binary is not executable.`);
514
+ console.error(`[INFO] To fix this, run: sudo chmod +x "${binaryPath}"`);
515
+ console.error(`[INFO] Or reinstall: npm install -g fnva --force`);
516
+ } else {
517
+ console.error(`[ERROR] Failed to execute fnva: ${result.error.message}`);
518
+ }
519
+ process.exit(result.status ?? 1);
520
+ }
521
+
522
+ process.exit(result.status ?? 0);
523
+ }
524
+
504
525
  if (isSwitchCommand) {
505
526
  const shellArg = getShellArg(args);
506
527
  if (!shellArg || shellArg === 'auto') {
@@ -615,11 +636,8 @@ function run() {
615
636
  }
616
637
  }
617
638
  } else {
618
- // Unix-like systems: 显示使用说明
619
- console.log(`[OK] Switched to ${envType} environment: ${envName}`);
620
- console.log('');
621
- console.log('[INFO] To apply this environment, run:');
622
- console.log(` node bin/fnva.js ${args.join(' ')} | bash`);
639
+ // Unix-like systems: output raw script for eval or wrapper function
640
+ process.stdout.write(script);
623
641
  }
624
642
  } else {
625
643
  // 如果不是环境脚本,直接输出
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -41,12 +41,12 @@ function getShellConfigPath(shell) {
41
41
  function getIntegrationLine(shell) {
42
42
  switch (shell) {
43
43
  case 'powershell':
44
- return 'fnva env --shell powershell | Out-String | Invoke-Expression';
44
+ return 'fnva env env --shell powershell | Out-String | Invoke-Expression';
45
45
  case 'bash':
46
46
  case 'zsh':
47
- return 'eval "$(fnva env --shell bash)"';
47
+ return 'eval "$(fnva env env --shell bash)"';
48
48
  case 'fish':
49
- return 'fnva env --shell fish | source';
49
+ return 'fnva env env --shell fish | source';
50
50
  default:
51
51
  return null;
52
52
  }
@@ -57,7 +57,7 @@ function isInstalled(configPath) {
57
57
  return false;
58
58
  }
59
59
  const content = fs.readFileSync(configPath, 'utf8');
60
- return content.includes('fnva env --shell');
60
+ return content.includes('fnva env env --shell');
61
61
  }
62
62
 
63
63
  function installShellIntegration() {