generated from remirror/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnpmfile.js
54 lines (46 loc) · 1.21 KB
/
pnpmfile.js
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
/**
* @explanation
*
* This file is used by pnpm to add hooks to the installation [process][1]. You
* can use it to perform the same functionality as found in yarn resolutions and
* other similar environments.
*/
module.exports = {
hooks: {
readPackage,
},
};
/**
* @param {import('type-fest').PackageJson} pkg
*/
function readPackage(pkg) {
const setDependency = createSetDependency(pkg);
setDependency('serialize-javascript', '^4.0.0');
return pkg;
}
/**
* @typedef {(name: string, version: string, includePeer?: boolean) => void} SetDependency
*/
/**
* A factory method which is used to create dependency setters for a provided
* package.json file.
*
* @param {import('type-fest').PackageJson} pkg
* @returns {SetDependency}
*/
function createSetDependency(pkg) {
return function (name, version, peer = false) {
if (pkg.dependencies && pkg.dependencies[name]) {
pkg.dependencies[name] = version;
}
if (pkg.devDependencies && pkg.devDependencies[name]) {
pkg.devDependencies[name] = version;
}
if (peer && pkg.peerDependencies && pkg.peerDependencies[name]) {
pkg.peerDependencies[name] = version;
}
};
}
/**
* [1]: https://pnpm.js.org/en/pnpmfile
*/