package.json & cache invalidation

I love the way appveyor can cache things like the node_modules folder in between builds of my app. But I've hit a snag and wonder if there is a good work around. I would like to invalidate the cache if the package.json file changes. But I need to update the version field in the package.json when I create a new version. So this means I'm invalidating the cache each time I bump the version, even if none of the dependencies change.

  1. My first thought was it's impossible as it just takes file CRC without looking inside.

    However, I've got an idea! There is a possibility to override clone script with your own custom script, something like:

    clone_script: |
      if(-not $env:appveyor_pull_request_number) {
          git clone -q --branch=$env:appveyor_repo_branch https://github.com/$env:appveyor_repo_name.git $env:appveyor_build_folder
          git checkout -qf $env:appveyor_repo_commit
      } else {
          git clone -q https://github.com/$env:appveyor_repo_name.git $env:appveyor_build_folder
          git fetch -q origin +refs/pull/$env:appveyor_pull_request_number/merge:
          git checkout -qf FETCH_HEAD
      }
    

    after cloning the repo you can copy package.json to something like package-no-ver.json and then using a simple script remove version information from package-no-ver.json. Then use package-no-ver.json as cache item dependency.

    Dirty hack, but might work :)

  2. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:06 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac