Skip to content

Commit 7036ea3

Browse files
committed
fix: broken version update script
1 parent 91d4b94 commit 7036ea3

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[
2222
"@semantic-release/exec",
2323
{
24-
"successCmd": "node version.cjs tag=${nextRelease.version}"
24+
"generateNotesCmd": "node version.cjs tag=${nextRelease.version}"
2525
}
2626
]
2727
],

scripts/update-version.cjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { readFile, writeFile } = require("fs/promises");
22
const { join } = require("path");
33
const [, tag] = process.argv.find((value) => value.startsWith("tag")).split("=");
4-
const splitAt = tag.lastIndexOf("-");
4+
const splitAt = tag.lastIndexOf("-v");
55
const pkgName = tag.substring(0, splitAt);
66
const version = tag.substring(splitAt + 2);
77

@@ -12,16 +12,32 @@ const version = tag.substring(splitAt + 2);
1212
* @returns {void}
1313
*/
1414
module.exports = async function (packages = [], dev = false) {
15+
console.log(
16+
"\x1b[34m%s\x1b[0m",
17+
`Updating dependant packages with "${pkgName}" version "${version}"`
18+
);
19+
1520
for (let index = 0; index < packages.length; index++) {
21+
console.log("\x1b[34m%s\x1b[0m", `Updating "${packages[index]}"`);
22+
1623
const pkgJSONPath = join(__dirname, "../packages", packages[index], "package.json");
1724
const pkgJSON = JSON.parse(await readFile(pkgJSONPath, { encoding: "utf8" }));
1825
const pkgType = dev ? "devDependencies" : "dependencies";
1926

20-
if (!pkgJSON[pkgType]?.[pkgName]) continue;
27+
if (!pkgJSON[pkgType]?.[pkgName]) {
28+
console.log(
29+
"\x1b[34m%s\x1b[0m",
30+
`Couldn't find "${pkgName}" in "${packages[index]}" ${pkgType}, skipping`
31+
);
32+
33+
continue;
34+
}
2135

2236
// update pkg version
2337
pkgJSON[pkgType][pkgName] = `^${version}`;
2438
// override existing file
2539
await writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2));
40+
41+
console.log("\x1b[34m%s\x1b[0m", `Succesfully updated "${packages[index]}" package`);
2642
}
2743
};

0 commit comments

Comments
 (0)