/
peerDependencies.ts
72 lines (64 loc) · 1.68 KB
/
peerDependencies.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import path from 'path'
import { add, install } from '@pnpm/plugin-commands-installation'
import prepare from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import tempy from 'tempy'
const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
const TMP = tempy.directory()
const DEFAULT_OPTIONS = {
argv: {
original: [],
},
bail: false,
bin: 'node_modules/.bin',
cacheDir: path.join(TMP, 'cache'),
extraEnv: {},
cliOptions: {},
include: {
dependencies: true,
devDependencies: true,
optionalDependencies: true,
},
lock: true,
pnpmfile: '.pnpmfile.cjs',
pnpmHomeDir: '',
rawConfig: { registry: REGISTRY_URL },
rawLocalConfig: { registry: REGISTRY_URL },
registries: {
default: REGISTRY_URL,
},
sort: true,
storeDir: path.join(TMP, 'store'),
userConfig: {},
workspaceConcurrency: 1,
}
test('root dependency that has a peer is correctly updated after its version changes', async () => {
const project = prepare({})
await add.handler({
...DEFAULT_OPTIONS,
dir: process.cwd(),
linkWorkspacePackages: true,
}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'])
{
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['ajv-keywords']).toBe('1.5.0_ajv@4.10.4')
}
await project.writePackageJson({
dependencies: {
ajv: '4.10.4',
'ajv-keywords': '1.5.1',
},
})
await install.handler({
...DEFAULT_OPTIONS,
dir: process.cwd(),
linkWorkspacePackages: true,
rawLocalConfig: {
'frozen-lockfile': false,
},
})
{
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['ajv-keywords']).toBe('1.5.1_ajv@4.10.4')
}
})