Skip to content

Commit 9b49787

Browse files
authored
Make rewatch version number same as rescript version number (#7584)
1 parent e21d7c2 commit 9b49787

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

rewatch/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rewatch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rewatch"
3-
version = "1.2.0"
3+
version = "12.0.0-alpha.15"
44
edition = "2021"
55

66
[dependencies]

yarn.config.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
const fs = require("node:fs/promises");
88
const { defineConfig } = require("@yarnpkg/types");
9+
const { exec } = require("node:child_process");
10+
const util = require("node:util");
11+
const execPromise = util.promisify(exec);
912

1013
/**
1114
* @param {Yarn.Constraints.Context} ctx
@@ -65,6 +68,29 @@ async function enforceCompilerMeta({ Yarn }) {
6568
);
6669
}
6770
}
71+
72+
const rewatchCargoFile = "rewatch/Cargo.toml";
73+
const rewatchCargoContent = await fs.readFile(rewatchCargoFile, "utf8");
74+
const rewatchVersionPattern = /^version = "(?<version>[^"]+)"$/m;
75+
76+
if (process.argv.includes("--fix")) {
77+
await fs.writeFile(
78+
rewatchCargoFile,
79+
rewatchCargoContent.replace(
80+
rewatchVersionPattern,
81+
`version = "${EXPECTED_VERSION}"`,
82+
),
83+
);
84+
await execPromise("cargo check", { cwd: "rewatch" });
85+
} else {
86+
const rewatchVersionMatch = rewatchCargoContent.match(rewatchVersionPattern);
87+
const foundRewatchVersion = rewatchVersionMatch?.groups?.version;
88+
if (foundRewatchVersion !== EXPECTED_VERSION) {
89+
Yarn.workspace().error(
90+
`rewatch/Cargo.toml file need to be fixed; expected ${EXPECTED_VERSION}, found ${foundRewatchVersion}.`,
91+
);
92+
}
93+
}
6894
}
6995

7096
module.exports = defineConfig({

0 commit comments

Comments
 (0)