Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
}