forked from neovateai/neovate-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pnpmfile.cjs
More file actions
46 lines (37 loc) · 1.2 KB
/
.pnpmfile.cjs
File metadata and controls
46 lines (37 loc) · 1.2 KB
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
// pnpm hooks to fix string-width version compatibility issues
// Downgrade string-width 8.x to 7.2.0 for certain packages
const TARGET_STRING_WIDTH_VERSION = '7.2.0';
const PACKAGES_TO_OVERRIDE = new Set(['ink', 'cli-truncate']);
function isVersion8(version) {
return typeof version === 'string' && version.includes('8.');
}
function overrideStringWidth(pkg, context, reason) {
pkg.dependencies = {
...pkg.dependencies,
'string-width': TARGET_STRING_WIDTH_VERSION,
};
context.log(`${reason} => string-width@${TARGET_STRING_WIDTH_VERSION}`);
}
function readPackage(pkg, context) {
if (!pkg.dependencies) {
return pkg;
}
const stringWidthVersion = pkg.dependencies['string-width'];
// Override specific packages known to have issues
if (PACKAGES_TO_OVERRIDE.has(pkg.name)) {
if (!stringWidthVersion || isVersion8(stringWidthVersion)) {
overrideStringWidth(pkg, context, pkg.name);
}
return pkg;
}
// Global override for any package using string-width 8.x
if (stringWidthVersion && isVersion8(stringWidthVersion)) {
overrideStringWidth(pkg, context, `${pkg.name} (string-width@8.x)`);
}
return pkg;
}
module.exports = {
hooks: {
readPackage,
},
};