pnpm-plugin-alex-857 1.0.29 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install-catalog.js +12 -9
- package/package.json +1 -1
package/install-catalog.js
CHANGED
|
@@ -21,18 +21,21 @@ if (specifiers.length === 0) {
|
|
|
21
21
|
process.exit(0);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
//
|
|
25
|
-
// was just created or config was wiped, skip so postinstall does not fail.
|
|
24
|
+
// Ensure pnpm-workspace.yaml has a catalog section so catalog: resolution works.
|
|
26
25
|
const workspaceYamlPath = path.join(process.cwd(), "pnpm-workspace.yaml");
|
|
27
26
|
if (fs.existsSync(workspaceYamlPath)) {
|
|
28
|
-
|
|
29
|
-
const hasCatalog =
|
|
30
|
-
/\ncatalog\s*:/m.test(yaml) || /\nconfigDependencies\s*:/m.test(yaml);
|
|
27
|
+
let yaml = fs.readFileSync(workspaceYamlPath, "utf8");
|
|
28
|
+
const hasCatalog = /\ncatalog\s*:/m.test(yaml);
|
|
31
29
|
if (!hasCatalog) {
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const catalogBlock =
|
|
31
|
+
"\ncatalog:\n" +
|
|
32
|
+
Object.entries(catalog)
|
|
33
|
+
.map(([name, version]) => ` ${name}: ${version}`)
|
|
34
|
+
.join("\n") +
|
|
35
|
+
"\n";
|
|
36
|
+
yaml = yaml.trimEnd() + catalogBlock;
|
|
37
|
+
fs.writeFileSync(workspaceYamlPath, yaml, "utf8");
|
|
38
|
+
console.log("Added catalog to pnpm-workspace.yaml");
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|