fix: installing git-hosted dependencies

Fixing a regression caused by breaking changes in the fetch function
API.
`@pnpm/git-fetcher` was not correctly updated.

As a result, git-hosted dependencies were not being installed.

PR #2580
This commit is contained in:
Zoltan Kochan
2020-05-28 12:21:32 +03:00
committed by GitHub
parent 78dc7aa518
commit 187615f871
6 changed files with 23 additions and 13 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/git-fetcher": patch
---
Adhere to the new FetchFunction API. cafs should be the first argument of the a fetch function.

View File

@@ -7,12 +7,13 @@ import tempy = require('tempy')
export default () => {
return {
git: async function fetchFromGit (
cafs: Cafs,
resolution: {
repo: string,
commit: string,
repo: string,
type: 'git',
},
opts: {
cafs: Cafs,
manifest?: DeferredManifestPromise,
}
) {
@@ -22,7 +23,7 @@ export default () => {
// removing /.git to make directory integrity calculation faster
await rimraf(path.join(tempLocation, '.git'))
return {
filesIndex: await opts.cafs.addFilesFromDir(tempLocation, opts.manifest),
filesIndex: await cafs.addFilesFromDir(tempLocation, opts.manifest),
}
},
}

View File

@@ -11,13 +11,17 @@ test('fetch', async t => {
t.comment(`cafs at ${cafsDir}`)
const fetch = createFetcher().git
const manifest = pDefer<DependencyManifest>()
const { filesIndex } = await fetch({
commit: 'c9b30e71d704cd30fa71f2edd1ecc7dcc4985493',
repo: 'https://github.com/kevva/is-positive.git',
}, {
cafs: createCafs(cafsDir),
manifest,
})
const { filesIndex } = await fetch(
createCafs(cafsDir),
{
commit: 'c9b30e71d704cd30fa71f2edd1ecc7dcc4985493',
repo: 'https://github.com/kevva/is-positive.git',
type: 'git',
},
{
manifest,
}
)
t.ok(filesIndex['package.json'])
t.ok(await filesIndex['package.json'].generatingIntegrity)
t.equal((await manifest.promise).name, 'is-positive')

View File

@@ -51,7 +51,7 @@ export default async function testDefaults (
registry,
...retryOpts,
...fetchOpts,
}) as {},
}),
{
storeDir,
...storeOpts,

View File

@@ -25,7 +25,7 @@ export default async (
await fs.mkdir(sopts.storeDir, { recursive: true })
const fetchers = createFetcher(sopts)
return {
ctrl: await createStore(resolve, fetchers as {}, {
ctrl: await createStore(resolve, fetchers, {
ignoreFile: sopts.ignoreFile,
networkConcurrency: sopts.networkConcurrency,
packageImportMethod: sopts.packageImportMethod,

View File

@@ -54,7 +54,7 @@ export default async function testDefaults<T> (
registry,
...retryOpts,
...fetchOpts,
}) as {},
}),
{
ignoreFile: opts?.fastUnpack === false ? undefined : (filename) => filename !== 'package.json',
storeDir,