sounisi5011/metalsmith-postcss2

View on GitHub
.template/azure-pipelines/steps/init-node.yml

Summary

Maintainability
Test Coverage
parameters:
  nodeVersion: 12.x

steps:
  - bash: |
      echo '##vso[task.setvariable variable=npm_config_cache]$(Pipeline.Workspace)/.npm'
    displayName: "Set variables: $npm_config_cache"

  - script: |
      node -p 'Object.entries(process.env).filter(([p]) => /^npm_config_cache$/i.test(p)).reduce((o, [p, v]) => ({...o, [p]:v}), {})'
    displayName: "Show variables: $npm_config_cache"

  - script:
      sudo sysctl fs.inotify.max_user_watches=524288
      # see https://github.com/ember-decorators/ember-decorators/commit/8bd65ec0ba4c7bc962434bcc35927f50a47a9db9
      # see https://stackoverflow.com/questions/22475849/node-js-error-enospc#32600959
      # see https://serv-ops.com/knowledge/open.knowledge/view/15
      # see https://www.virment.com/how-to-fix-system-limit-for-number-of-file-watchers-reached/
      #
      # Note: The maximum value for max_user_watches is 524288
      #       see https://qiita.com/neuwell/items/c827c80673de0d787d41
    displayName: Fixes an issue where the max file watch count is exceeded, triggering ENOSPC

  - task: NodeTool@0
    inputs:
      versionSpec: ${{ parameters.nodeVersion }}
    displayName: Install Node.js

  - bash: |
      echo node $(node --version)
      echo npm $(npm --version)
    displayName: Show node and npm version

  - task: Cache@2
    inputs:
      key: 'npm | "$(Agent.OS)" | package-lock.json'
      restoreKeys: |
        npm | "$(Agent.OS)"
        npm
      path: $(npm_config_cache)
    displayName: Cache npm

  - script: npm ci || npm install
    displayName: Install dependencies