tag:help.appveyor.com,2012-11-13:/discussions/questions/27642-conditional-cache-folderAppVeyor: Discussion 2018-12-17T21:00:23Ztag:help.appveyor.com,2012-11-13:Comment/462259112018-10-09T09:20:33Z2018-10-09T09:20:33ZConditional cache folder<div><p>Hello.</p>
<p>I'm trying to switch to AppVeyor for both Linux and Windows testing for a project f mine. So far everything is good minus one thing: I can't figure out how to conditionally set the npm cache folder so that it works cross-platform</p>
<pre>
<code>cache:
- '%APPDATA%\npm-cache\ -> .appveyor.yml,package.json,package-lock.json' # need this only on Windows
- '$HOME/.npm -> .appveyor.yml,package.json,package-lock.json' # need this only on Linux</code>
</pre>
<p>IMO this should be documented too.</p>
<p>Thanks in advance!</p></div>xhmikosrtag:help.appveyor.com,2012-11-13:Comment/462259112018-10-09T15:18:01Z2018-10-09T15:18:01ZConditional cache folder<div><p>You can mix windows and linux paths in the same cache list and ones not relevant to the OS should be not found and therefore ignored.</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/462259112018-10-09T15:19:50Z2018-10-09T15:19:50ZConditional cache folder<div><p>Well, yeah that's what I'm doing. But there must be some proper way, without having the warning thrown.</p></div>xhmikosrtag:help.appveyor.com,2012-11-13:Comment/462259112018-10-10T17:01:54Z2018-10-10T17:01:54ZConditional cache folder<div><p>Ok, if you want to avoid the warning then put the cache in a <code>for:</code> construct. Like this,</p>
<pre>
<code>for:
-
matrix:
only:
- image: Visual Studio 2017
cache:
- '%APPDATA%\npm-cache\ -> .appveyor.yml,package.json,package-lock.json' # need this only on Windows
-
matrix:
only:
- image: Ubuntu
cache:
- '$HOME/.npm -> .appveyor.yml,package.json,package-lock.json' # need this only on Linux</code>
</pre></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/462259112018-10-15T07:41:02Z2018-10-15T07:41:02ZConditional cache folder<div><p>Thanks, this works.</p>
<p>Could it be documented though?</p></div>xhmikosrtag:help.appveyor.com,2012-11-13:Comment/462259112018-10-16T22:28:28Z2018-10-16T22:28:28ZConditional cache folder<div><p>Specializing build matrix job config is documented <a href="https://www.appveyor.com/docs/build-configuration/#specializing-matrix-job-configuration">here</a> though <code>cache:</code> is not explicitly mentioned.</p>
<p>I think you have a point that it should be.</p>
<p>Our <a href="https://github.com/appveyor/website">docs</a> are open source and pull requests are welcome!</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/462259112018-10-17T07:38:53Z2018-10-17T07:38:53ZConditional cache folder<div><p>Haha, I know they are open-source :) Just check the git log in the website repo.</p>
<p>But anyway, not sure how to phrase this thus the request.</p></div>xhmikosrtag:help.appveyor.com,2012-11-13:Comment/462259112018-10-17T16:29:42Z2018-10-17T16:29:42ZConditional cache folder<div><p>I would just add another YAML sample. Because we list settings which are <strong>ignored</strong> in <code>matrix.for</code> construct, all other are respected.</p></div>Ilya Finkelshteyn