Skip to content

Commit 6e4f1d3

Browse files
committed
don't warm cache with registry responses when we have a possible offline path - fixes #75
1 parent a01a88d commit 6e4f1d3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/package-request.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,30 @@ export default class PackageRequest {
259259
// only do this in strict lockfile mode as otherwise we can just use our root lockfile
260260
let subLockfile = null;
261261
if (!this.resolver.lockfile.strict) {
262+
// get possible mirror path
263+
let offlineMirrorPath = this.config.getOfflineMirrorPath(ref.remote.registry, ref.remote.reference);
264+
262265
// while we're fetching the package we have some idle time to warm the cache with
263266
// registry responses for known dependencies
264-
for (let name in info.dependencies) {
265-
// TODO not needed for offline installation
266-
this.warmCacheIfRegistry(`${name}@${info.dependencies[name]}`);
267+
if (!offlineMirrorPath) {
268+
for (let name in info.dependencies) {
269+
this.warmCacheIfRegistry(`${name}@${info.dependencies[name]}`);
270+
}
267271
}
268272

269273
//
270274
let { package: newInfo, hash, dest } = await this.resolver.fetchingQueue.push(
271275
info.name,
272276
() => this.resolver.fetcher.fetch(ref)
273277
);
274-
let offlineMirrorPath = this.config.getOfflineMirrorPath(ref.remote.registry, ref.remote.reference);
275-
// replace resolved remote URL with local path
278+
279+
// replace resolved remote URL with local path if lockfile is in save mode and we have a path
276280
if (this.resolver.lockfile.save && offlineMirrorPath) {
277281
if (await fs.exists(offlineMirrorPath)) {
278282
remote.resolved = path.relative(
279283
this.config.getOfflineMirrorPath(ref.remote.registry),
280-
offlineMirrorPath) + `#${ref.remote.hash}`;
284+
offlineMirrorPath
285+
) + `#${ref.remote.hash}`;
281286
}
282287
}
283288
remote.hash = hash;

0 commit comments

Comments
 (0)