Skip to content

Instantly share code, notes, and snippets.

@corradin
Last active July 26, 2023 12:14
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corradin/1b2db5c54f85c818f093ddd028351bd7 to your computer and use it in GitHub Desktop.
Save corradin/1b2db5c54f85c818f093ddd028351bd7 to your computer and use it in GitHub Desktop.
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: Cache@2
inputs:
key: 'package-lock.json'
path: $(npm_config_cache)
displayName: Cache NPM packages
- script: npm ci --cache $(npm_config_cache)
displayName: NPM Install Dependencies
- script: |
npm cache ls
npm cache verify
displayName: NPM Show cache
- script: npm run lint
displayName: Lint
- script: npm run test:ci
displayName: Unit Tests
- script: npm run build
displayName: Build
@Excalibaard
Copy link

Excalibaard commented Mar 1, 2023

Read the blog, thanks for making this available!

Is the --cache flag necessary, or done to make the caching location more explicit? During my search to resolve some npm caching issues in our pipeline I came across this comment that environment variables are automatically read by npm, and the azure docs don't include the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment