fnva 0.0.48 → 0.0.49

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
@@ -15,7 +15,7 @@ Cross-platform environment switcher for Java, Claude Code (CC), and LLM setups.
15
15
  ## Quick start
16
16
 
17
17
  - Init shell (Bash/Zsh): `eval "$(fnva env env --shell bash)"`
18
- PowerShell: `fnva env env --shell powershell | Out-String | Invoke-Expression`
18
+ PowerShell: `Invoke-Expression (& fnva env env --shell powershell | Out-String)`
19
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnva",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "description": "跨平台环境切换工具,支持 Java 和 LLM 环境配置",
5
5
  "author": "protagonistss",
6
6
  "license": "MIT",
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -18,15 +18,24 @@ function detectShell() {
18
18
  return process.env.SHELL?.split('/').pop() || 'bash';
19
19
  }
20
20
 
21
+ function getPowershellProfilePath() {
22
+ const home = process.env.USERPROFILE || os.homedir();
23
+ // Check PowerShell 7 first (pwsh), then fall back to Windows PowerShell 5.x
24
+ const ps7Profile = path.join(home, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1');
25
+ const ps5Profile = path.join(home, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1');
26
+ // If PS7 profile already exists, use it; otherwise prefer PS7 path
27
+ if (fs.existsSync(ps7Profile)) return ps7Profile;
28
+ if (fs.existsSync(ps5Profile)) return ps5Profile;
29
+ // Detect which PowerShell is installed via pwsh vs powershell
30
+ const pwshResult = spawnSync('pwsh', ['-NoProfile', '-Command', 'echo true'], { timeout: 5000 });
31
+ if (pwshResult.status === 0) return ps7Profile;
32
+ return ps5Profile;
33
+ }
34
+
21
35
  function getShellConfigPath(shell) {
22
36
  switch (shell) {
23
37
  case 'powershell':
24
- return path.join(
25
- process.env.USERPROFILE || os.homedir(),
26
- 'Documents',
27
- 'WindowsPowerShell',
28
- 'Microsoft.PowerShell_profile.ps1'
29
- );
38
+ return getPowershellProfilePath();
30
39
  case 'bash':
31
40
  return path.join(os.homedir(), '.bashrc');
32
41
  case 'zsh':
@@ -41,7 +50,7 @@ function getShellConfigPath(shell) {
41
50
  function getIntegrationLine(shell) {
42
51
  switch (shell) {
43
52
  case 'powershell':
44
- return 'fnva env env --shell powershell | Out-String | Invoke-Expression';
53
+ return 'Invoke-Expression (& fnva env env --shell powershell | Out-String)';
45
54
  case 'bash':
46
55
  case 'zsh':
47
56
  return 'eval "$(fnva env env --shell bash)"';