11cb0ef41Sopenharmony_ci#!/usr/bin/env pwsh 21cb0ef41Sopenharmony_ci$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci$exe="" 51cb0ef41Sopenharmony_ciif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { 61cb0ef41Sopenharmony_ci # Fix case when both the Windows and Linux builds of Node 71cb0ef41Sopenharmony_ci # are installed in the same directory 81cb0ef41Sopenharmony_ci $exe=".exe" 91cb0ef41Sopenharmony_ci} 101cb0ef41Sopenharmony_ci$ret=0 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci$nodeexe = "node$exe" 131cb0ef41Sopenharmony_ci$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source 141cb0ef41Sopenharmony_ciif ($nodebin -eq $null) { 151cb0ef41Sopenharmony_ci Write-Host "$nodeexe not found." 161cb0ef41Sopenharmony_ci exit 1 171cb0ef41Sopenharmony_ci} 181cb0ef41Sopenharmony_ci$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci$npmclijs="$nodedir/node_modules/npm/bin/npm-cli.js" 211cb0ef41Sopenharmony_ci$npmprefix=(& $nodeexe $npmclijs prefix -g) 221cb0ef41Sopenharmony_ciif ($LASTEXITCODE -ne 0) { 231cb0ef41Sopenharmony_ci Write-Host "Could not determine Node.js install directory" 241cb0ef41Sopenharmony_ci exit 1 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci$npmprefixclijs="$npmprefix/node_modules/npm/bin/npm-cli.js" 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci# Support pipeline input 291cb0ef41Sopenharmony_ciif ($MyInvocation.ExpectingInput) { 301cb0ef41Sopenharmony_ci $input | & $nodeexe $npmprefixclijs $args 311cb0ef41Sopenharmony_ci} else { 321cb0ef41Sopenharmony_ci & $nodeexe $npmprefixclijs $args 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci$ret=$LASTEXITCODE 351cb0ef41Sopenharmony_ciexit $ret 36