Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bb4b44f0-f505-49c5-9878-76e2b40c7a15 Copilot-Session: 8eac1204-10ae-4319-9333-aee5dd43dcc8
21 lines
646 B
JavaScript
21 lines
646 B
JavaScript
// Print the docs URL slug for a source tree's VersionPrefix.
|
|
//
|
|
// Usage:
|
|
// node scripts/get-docs-version-slug.mjs <src/Directory.Build.props>
|
|
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
const propsPath = process.argv[2];
|
|
if (!propsPath) {
|
|
console.error("usage: get-docs-version-slug.mjs <src/Directory.Build.props>");
|
|
process.exit(2);
|
|
}
|
|
|
|
const props = await readFile(propsPath, "utf8");
|
|
const match = props.match(/<VersionPrefix>\s*([1-9][0-9]*)\.\d+\.\d+\s*<\/VersionPrefix>/);
|
|
if (!match) {
|
|
console.error(`error: unable to determine VersionPrefix from ${propsPath}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
process.stdout.write(`v${match[1]}\n`);
|