Skip to content

Commit cddf727

Browse files
committed
Add test to ensure all project version numbers match.
1 parent a1f74ab commit cddf727

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/markdownlint-cli2-test.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,42 @@ test("name and version", (t) => {
4646
then((exitCode) => t.is(exitCode, 2));
4747
});
4848

49+
test("version numbers match", async (t) => {
50+
t.plan(142);
51+
const files = [
52+
// See previous test
53+
// "./package.json",
54+
"./.pre-commit-hooks.yaml",
55+
"./CHANGELOG.md",
56+
"./README.md",
57+
"./doc/OutputFormatters.md",
58+
"./schema/markdownlint-cli2-config-schema.json",
59+
"./schema/markdownlint-config-schema.json"
60+
];
61+
const packages = [
62+
// eslint-disable-next-line prefer-named-capture-group
63+
[ packageJson.version, /(?:DavidAnson\/markdownlint-cli2\/|markdownlint-cli2\/blob\/|davidanson\/markdownlint-cli2(?:-rules)?:|rev: )v(\d+\.\d+\.\d+)/gu ],
64+
// eslint-disable-next-line prefer-named-capture-group
65+
[ packageJson.dependencies.markdownlint, /(?:DavidAnson\/markdownlint|markdownlint\/blob)\/v(\d+\.\d+\.\d+)/gu ]
66+
];
67+
const contents = await Promise.all(files.map((file) => fs.readFile(file, "utf8")));
68+
for (const content of contents) {
69+
// eslint-disable-next-line init-declarations
70+
let match;
71+
for (const [ version, githubProjectOrFileRe ] of packages) {
72+
while ((match = githubProjectOrFileRe.exec(content)) !== null) {
73+
t.is(match[1], version);
74+
}
75+
}
76+
// eslint-disable-next-line prefer-named-capture-group
77+
const firstChangelogRe = /## (\d+\.\d+\.\d+)/u;
78+
match = firstChangelogRe.exec(content);
79+
if (match) {
80+
t.is(match[1], packageJson.version);
81+
}
82+
}
83+
});
84+
4985
test("README files", (t) => {
5086
t.plan(1);
5187
const uncalled = (/** @type {string} */ msg) => t.fail(`message logged: ${msg}`);

0 commit comments

Comments
 (0)