fix(rewrite): Fix setup.mjs on Unix-like systems

This commit is contained in:
tecc 2023-09-15 23:25:11 +02:00
parent 555cecb58f
commit 1e2b321bd8
No known key found for this signature in database
GPG Key ID: 622EEC5BAE5EBD3A

View File

@ -7,26 +7,24 @@ console.log("Setting up project");
let currentlySettingUp = "";
const url = new URL(import.meta.url);
let projectDir = path.resolve(
url.pathname
.split("/")
.filter((v) => v && v.length > 0)
.join(path.sep)
);
let projectDir = url.pathname
.split("/")
.filter((v) => v && v.length > 0)
.join(path.sep)
// This is a cheap but probably check to see if we're *not* on Windows.
if (path.sep !== "\\") {
// You could inline `path.sep` as "\" but why not go that extra mile
// We're already using it so
projectDir = path.sep + projectDir;
}
projectDir = path.dirname(projectDir);
projectDir = path.dirname(path.resolve(projectDir));
const legacyDir = path.resolve(projectDir, "..");
function message(str) {
let prefix = "";
if (!!currentlySettingUp && currentlySettingUp.trim().length >= 0) {
prefix = `[${currentlySettingUp}]`;
prefix = `[${currentlySettingUp}] `;
}
console.log(" " + prefix + str);
}