mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-23 17:32:22 +00:00
Fix Cross platform building of Draupnir
This commit is contained in:
5 files changed
+54
-4
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2026 Catalan Lover <catalanlover@protonmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: 0BSD
|
||||
|
||||
// Cross-platform replacement for the old mv/rm shell one-liners (Windows cmd.exe has neither).
|
||||
const { execSync } = require("node:child_process");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const targets = {
|
||||
version: {
|
||||
command: "git describe",
|
||||
file: path.join(__dirname, "..", "version.txt"),
|
||||
},
|
||||
branch: {
|
||||
command: "git rev-parse --abbrev-ref HEAD",
|
||||
file: path.join(__dirname, "..", "branch.txt"),
|
||||
},
|
||||
};
|
||||
|
||||
function writeBuildInfo(target) {
|
||||
const { command, file } = targets[target];
|
||||
try {
|
||||
const output = execSync(command, { encoding: "utf-8" }).trim();
|
||||
fs.writeFileSync(file, output + "\n");
|
||||
} catch {
|
||||
// git may be unavailable, this may not be a repo, or there may be no tags/HEAD.
|
||||
// config.ts already falls back to package.json's version / a default message.
|
||||
}
|
||||
}
|
||||
|
||||
const target = process.argv[2];
|
||||
if (!targets[target]) {
|
||||
console.error(
|
||||
`Usage: node write-build-info.cjs <${Object.keys(targets).join("|")}>`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
writeBuildInfo(target);
|
||||
Reference in new issue
Block a user