refactor(fetch): remove ctx from fetch()

This commit is contained in:
zkochan
2017-02-15 00:24:15 +02:00
parent efc60c8d9a
commit f205df13d9
2 changed files with 10 additions and 4 deletions

View File

@@ -23,11 +23,11 @@ export type FetchedPackage = {
path: string,
srcPath?: string,
id: string,
resolution: Resolution,
abort(): Promise<void>,
}
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<Boolean>,
}
): Promise<FetchedPackage> {
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 = <string>pkgId
const target = path.join(options.storePath, id)
const fetchingFiles = ctx.fetchingLocker(id, () => fetchToStore({
const fetchingFiles = options.fetchingLocker(id, () => fetchToStore({
target,
resolution: <Resolution>resolution,
loggedPkg,
@@ -93,6 +93,7 @@ export default async function fetch (
fetchingPkg,
fetchingFiles,
id,
resolution,
path: target,
srcPath: resolution.type == 'directory'
? resolution.root

View File

@@ -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