-
Notifications
You must be signed in to change notification settings - Fork 13
/
.pnpmfile.cjs
36 lines (31 loc) · 1.16 KB
/
.pnpmfile.cjs
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
const OMIT_DEPENDENCIES = ['@types/react', 'react', 'react-dom', 'slate', 'slate-react', 'slate-history'];
function readPackage(pkg, context) {
if (pkg.name === '@prezly/slate') {
// do not modify the workspace root package.json
return pkg;
}
OMIT_DEPENDENCIES.forEach((dependencyName) => {
if (pkg.peerDependencies && pkg.peerDependencies[dependencyName]) {
pkg.peerDependencies = omitDependency(pkg.peerDependencies, dependencyName);
context.log(`Skipping "${dependencyName}" from "${pkg.name}" peerDependencies.`);
}
if (pkg.dependencies && pkg.dependencies[dependencyName]) {
pkg.dependencies = omitDependency(pkg.dependencies, dependencyName);
context.log(`Skipping "${dependencyName}" from "${pkg.name}" dependencies.`);
}
});
return pkg;
}
/**
* @param {Record<string,string>} dependencies
* @param {string} omit
* @returns {Record<string,string>}
*/
function omitDependency(dependencies, omit) {
return Object.fromEntries(Object.entries(dependencies).filter(([name]) => name !== omit));
}
module.exports = {
hooks: {
readPackage,
},
};