From f205df13d96abc6f9c4dcce604744e9003d98d8a Mon Sep 17 00:00:00 2001 From: zkochan Date: Wed, 15 Feb 2017 00:24:15 +0200 Subject: [PATCH] refactor(fetch): remove ctx from fetch() --- src/install/fetch.ts | 7 ++++--- src/install/installMultiple.ts | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/install/fetch.ts b/src/install/fetch.ts index 9e8787902e..b4ffafc5b6 100644 --- a/src/install/fetch.ts +++ b/src/install/fetch.ts @@ -23,11 +23,11 @@ export type FetchedPackage = { path: string, srcPath?: string, id: string, + resolution: Resolution, abort(): Promise, } export default async function fetch ( - ctx: InstallContext, spec: PackageSpec, options: { linkLocal: boolean, @@ -39,6 +39,7 @@ export default async function fetch ( update?: boolean, shrinkwrapResolution?: Resolution, pkgId?: string, + fetchingLocker: MemoizedFunc, } ): Promise { logger.debug('installing ' + spec.raw) @@ -70,14 +71,13 @@ export default async function fetch ( if (resolveResult.package) { fetchingPkg = Promise.resolve(resolveResult.package) } - ctx.shrinkwrap.packages[resolveResult.id] = {resolution} } const id = pkgId const target = path.join(options.storePath, id) - const fetchingFiles = ctx.fetchingLocker(id, () => fetchToStore({ + const fetchingFiles = options.fetchingLocker(id, () => fetchToStore({ target, resolution: resolution, loggedPkg, @@ -93,6 +93,7 @@ export default async function fetch ( fetchingPkg, fetchingFiles, id, + resolution, path: target, srcPath: resolution.type == 'directory' ? resolution.root diff --git a/src/install/installMultiple.ts b/src/install/installMultiple.ts index 99f017af1e..d0ee0c5225 100644 --- a/src/install/installMultiple.ts +++ b/src/install/installMultiple.ts @@ -176,10 +176,15 @@ async function install ( const keypath = options.keypath || [] const update = keypath.length <= options.depth - const fetchedPkg = await fetch(ctx, spec, Object.assign({}, options, { + const fetchedPkg = await fetch(spec, Object.assign({}, options, { update, shrinkwrapResolution: options.dependencyShrinkwrap && options.dependencyShrinkwrap.resolution, + fetchingLocker: ctx.fetchingLocker, })) + + ctx.shrinkwrap.packages[fetchedPkg.id] = ctx.shrinkwrap.packages[fetchedPkg.id] || {} + ctx.shrinkwrap.packages[fetchedPkg.id].resolution = fetchedPkg.resolution + logFetchStatus(spec.rawSpec, fetchedPkg) const pkg = await fetchedPkg.fetchingPkg