-
Notifications
You must be signed in to change notification settings - Fork 1.3k
User configurable cache folder for binary download #1714
Conversation
@mriehema I think I figured out a version that will play nice with |
@xzyfer here is what I tried for manual testing
Not sure what automated tests can be setup for this one though |
Arg, Node 0.10 support strikes again https://travis-ci.org/nschonni/node-sass/jobs/158644756#L308 |
f082aa4
to
0b2ca70
Compare
@nschonni I will take a look the next days ASAP. Thank you for supporting my topic. |
Using the npm cache was discussed (maybe offline, my bad). The problem is a lot of environments will clear the npm cache. This super common on CI and containers because the npm cache can cause weird side-effects between builds. So counter intuitively the places that would likely benefit the most from local binary caching wouldn't use it. Caching the binaries in My preference would be to have a location configurable using ENV vars like the rest of the binary download config. The npm config dir could be good default location, but I expect to really see much value you'd need to set it to something distinct from npm. |
No. This is a known limitation with cross-spawn. We just don't use sync. From their docs
|
Containers would lose the TMP the same why as the NPM cache. CI wise-its the same logic as we currently use Line 32 in 105cca2
That case already got covered by our other binary path options, this just adds resilincy for offline NPM installs without having an external setup. That said, i'm not married to the approach, but I think this addresses the original concern in #1554 without adding more switches 😉 |
Thansk, I'll change my spawn to the async version, and replace the fs.existsSync since I didn't realize it was depricated. |
Correct, but to my point, containerised/CI envs can easily to opt-in to keeping it around without risking npm side effects. Keeping the npm cache around is much more troublesome so you want these two decoupled.
These don't provide the fallback to vendor which is the big win here. I would expect this to fallback to
Sane defaults are always better than switches, but giving users the ability to do what's best for their environment via switches when the defaults aren't sane for them is necessary. |
Sorry ignore the last push, it's not done yet. Forgot to set |
d09992e
to
1a655ac
Compare
@xzyfer should be good to go now. The Appveyor failure seems like a weird unrelated npm issue where it can't find right version
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, just checked out your branch and tested it on my Win7, 64bit machine. Works online, offline, with cleaned vendor directory, cleaned npm-cache.
Works perfectly and is so much faster. Thank you!
👍 🎉
}); | ||
var cachePath = path.join(sass.getCachePath(), pkg.name, pkg.version); | ||
var cacheBinary = path.join(cachePath, sass.getBinaryName()); | ||
if (!fs.existsSync(cacheBinary)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: avoid negative conditional with an else branch. Inverting this if
makes it much easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lgtm |
1a655ac
to
415e74d
Compare
Is it possible to get some test coverage over these changes? I'd hate to break installs in the future. |
New order of operations 1. Look for existing binary in vendor folder 2. Create target vendor folder 3. Look to see if we’ve cached a copy in the configured or NPM cache 4. Download to current version’s /CACHE/node-sass/version/binding_file 5. Copy the cached download to the regular vendor directory Closes sass#1566
415e74d
to
b655852
Compare
I added a small test and slightly renamed the config key so it's less likely to be confused with the Ruby Sass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
New order of operations
Closes #1566