fix generate-config-doc.js

It errored out with
> Error: Cannot find module '../server/log'
Which is expected, but we don't really need it, we can just open code
the log functions
This commit is contained in:
Reto Brunner 2024-04-07 16:22:08 +02:00
parent f5867c3643
commit 2466c1b1e4

View file

@ -10,10 +10,35 @@
const {readFileSync, writeFileSync} = require("fs");
const colors = require("chalk");
const log = require("../server/log").default;
const {join} = require("path");
const {spawnSync} = require("child_process");
function timestamp() {
const datetime = new Date().toISOString().split(".")[0].replace("T", " ");
return colors.dim(datetime);
}
const log = {
/* eslint-disable no-console */
error(...args) {
console.error(timestamp(), colors.red("[ERROR]"), ...args);
},
warn(...args) {
console.error(timestamp(), colors.yellow("[WARN]"), ...args);
},
info(...args) {
console.log(timestamp(), colors.blue("[INFO]"), ...args);
},
debug(...args) {
console.log(timestamp(), colors.green("[DEBUG]"), ...args);
},
raw(...args) {
console.log(...args);
},
/* eslint-enable no-console */
};
function getGitUsername() {
return spawnSync("git", ["config", "user.name"], {encoding: "utf8"}).stdout.trim();
}