File Coverage

blib/lib/NVMPL/Shell/PowerShell.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package NVMPL::Shell::PowerShell;
2 2     2   4229 use strict;
  2         5  
  2         162  
3 2     2   15 use warnings;
  2         5  
  2         133  
4 2     2   14 use feature 'say';
  2         4  
  2         234  
5 2     2   15 use NVMPL::Utils qw(log_info);
  2         3  
  2         436  
6              
7             # ---------------------------------------------------------
8             # Update PATH (used for shell printouts, rarely called)
9             # ---------------------------------------------------------
10             sub update_path {
11 1     1 0 1488 my ($bin_path) = @_;
12 1         45 say '$Env:PATH = "' . $bin_path . ';$Env:PATH"';
13             }
14              
15             # ---------------------------------------------------------
16             # Initialization snippet for PowerShell profile
17             # ---------------------------------------------------------
18             sub init_snippet {
19 1     1 0 4170 return <<'EOS';
20             # nvm-pl managed Node.js path (Windows-aware)
21             $CurrentNodePath = "$env:USERPROFILE\.nvm-pl\install\versions\current"
22              
23             if (Test-Path $CurrentNodePath) {
24             # Look for nested node-v*-win-x64 folder (typical Windows layout)
25             $NodeFolder = Get-ChildItem $CurrentNodePath -Directory -Filter "node-v*-win-x64" -ErrorAction SilentlyContinue | Select-Object -First 1
26             if ($NodeFolder) {
27             $NodeBin = $NodeFolder.FullName
28             } else {
29             $NodeBin = $CurrentNodePath
30             }
31              
32             if (-not ($env:PATH -like "*$NodeBin*")) {
33             $env:PATH = "$NodeBin;" + $env:PATH
34             }
35             }
36             EOS
37             }
38              
39             1;