Skip to content

Commit

Permalink
fix: better way to handle the global npm cache path
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehonal authored Feb 25, 2024
1 parent f4b564a commit a2a0ea6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions node-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ runs:
node_version: ${{ inputs.node_version }}
package_json_path: ${{ env.NODE_MODULE_DIR }}/${{ inputs.package_json_file }}

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- name: Cache global npm
uses: actions/cache@v4
if: ( inputs.cache_global_npm_modules )
env:
cache-name: cache-${{ inputs.project_id }}-global-node-modules
NODE_MODULE_DIR: ${{ inputs.package_json_dir || github.workspace }}
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles(format('{0}/package-lock.json', env.NODE_MODULE_DIR )) }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
Expand Down

0 comments on commit a2a0ea6

Please sign in to comment.