Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
localAddress?: string,
lockfileDir?: string,
offline?: boolean,
dir: string,
proxy?: string,
rawConfig: object,
registries: Registries,
storeDir?: string,
strictSsl?: boolean,
userAgent?: string,
verifyStoreIntegrity?: boolean,
workspaceDir: string,
},
) {
const storeDir = await storePath(opts.workspaceDir, opts.storeDir)
const resolve = createResolver(Object.assign(opts, {
fullMetadata: true,
metaCache: new LRU({
max: 10000,
maxAge: 120 * 1000, // 2 minutes
}) as any, // tslint:disable-line:no-any
storeDir,
})) as unknown as ResolveFunction
const pkgsToPublish = await pFilter(pkgs, async (pkg) => {
if (!pkg.manifest.name || !pkg.manifest.version || pkg.manifest.private) return false
return !(await isAlreadyPublished({
dir: pkg.dir,
lockfileDir: opts.lockfileDir || pkg.dir,
registries: opts.registries,
resolve,
}, pkg.manifest.name, pkg.manifest.version))
})
export default function createResolver (
pnpmOpts: ResolverFactoryOptions,
): ResolveFunction {
const resolveFromNpm = createResolveFromNpm(pnpmOpts)
const resolveFromGit = createResolveFromGit(pnpmOpts)
return async (wantedDependency, opts) => {
const resolution = await resolveFromNpm(wantedDependency, opts as ResolveFromNpmOptions)
|| wantedDependency.pref && (
await resolveFromTarball(wantedDependency as {pref: string})
|| await resolveFromGit(wantedDependency as {pref: string})
|| await resolveFromLocal(wantedDependency as {pref: string}, opts)
)
if (!resolution) {
throw new Error(`Cannot resolve ${wantedDependency.alias ? wantedDependency.alias + '@' : ''}${wantedDependency.pref} packages not supported`)
}
return resolution
}
}