Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ jobs:
version: 'latest'
node-version: '22'
package-manager: 'pnpm'
# Lock file is in test-fixtures to avoid Angular CLI auto-detecting pnpm in npm/yarn jobs
cache-dependency-path: '.github/test-fixtures/pnpm-lock.yaml'
# Disable cache: setup-node pnpm store caching is unreliable on Windows
# when using pnpm/action-setup@v4 (non-standard PNPM_HOME path).
# Core functionality (ng on PATH, version detection) is still tested.
cache: 'false'

- name: Verify CLI version output is set
shell: bash
Expand Down
20 changes: 12 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ runs:
env:
INPUT_PM: ${{ inputs.package-manager }}
run: |
# Read version directly from the installed package.json — no PATH dependency
if [ "$INPUT_PM" = "pnpm" ]; then
CLI_ROOT=$(pnpm root -g 2>/dev/null || echo "")
# pnpm list -g --json is reliable regardless of store location
CLI_VERSION=$(pnpm list -g @angular/cli --json 2>/dev/null | node -e \
"let b='';process.stdin.on('data',c=>b+=c);process.stdin.on('end',()=>{try{const a=JSON.parse(b);const i=Array.isArray(a)?a[0]:a;process.stdout.write(i?.dependencies?.['@angular/cli']?.version||'unknown')}catch(e){process.stdout.write('unknown')}})" \
2>/dev/null || echo "unknown")
elif [ "$INPUT_PM" = "yarn" ]; then
CLI_ROOT="$(yarn global dir 2>/dev/null)/node_modules"
export CLI_ROOT="$(yarn global dir 2>/dev/null)/node_modules"
CLI_VERSION=$(node -e \
"try{process.stdout.write(require(process.env.CLI_ROOT+'/@angular/cli/package.json').version)}catch(e){process.stdout.write('unknown')}" \
2>/dev/null || echo "unknown")
else
CLI_ROOT=$(npm root -g 2>/dev/null || echo "")
export CLI_ROOT=$(npm root -g 2>/dev/null || echo "")
CLI_VERSION=$(node -e \
"try{process.stdout.write(require(process.env.CLI_ROOT+'/@angular/cli/package.json').version)}catch(e){process.stdout.write('unknown')}" \
2>/dev/null || echo "unknown")
fi
export CLI_ROOT
CLI_VERSION=$(node -e \
"try{process.stdout.write(require(process.env.CLI_ROOT+'/@angular/cli/package.json').version)}catch(e){process.stdout.write('unknown')}" \
2>/dev/null || echo "unknown")
echo "cli-version=${CLI_VERSION:-unknown}" >> "$GITHUB_OUTPUT"
Loading