chore: reformat with 2 spaces

This commit is contained in:
Johannes Loher 2023-07-10 22:23:13 +02:00
parent d659e4bed9
commit 7670d7f808
No known key found for this signature in database
GPG key ID: 7CB0A9FB553DA045
1577 changed files with 70010 additions and 70042 deletions

View file

@ -13,43 +13,43 @@ import { destinationDirectory, distDirectory, foundryconfigFile, name } from "./
* Get the data path of Foundry VTT based on what is configured in the {@link foundryconfigFile}.
*/
function getDataPath() {
const config = fs.readJSONSync(foundryconfigFile);
const config = fs.readJSONSync(foundryconfigFile);
if (config?.dataPath) {
if (!fs.existsSync(path.resolve(config.dataPath))) {
throw new Error("User data path invalid, no Data directory found");
}
return path.resolve(config.dataPath);
} else {
throw new Error(`No user data path defined in ${foundryconfigFile}`);
if (config?.dataPath) {
if (!fs.existsSync(path.resolve(config.dataPath))) {
throw new Error("User data path invalid, no Data directory found");
}
return path.resolve(config.dataPath);
} else {
throw new Error(`No user data path defined in ${foundryconfigFile}`);
}
}
/**
* Link the built package to the user data folder.
* @param {boolean} clean Whether to remove the link instead of creating it
*/
async function linkPackage(clean) {
if (!fs.existsSync(path.resolve("system.json"))) {
throw new Error("Could not find system.json");
}
if (!fs.existsSync(path.resolve("system.json"))) {
throw new Error("Could not find system.json");
}
const linkDirectory = path.resolve(getDataPath(), "Data", destinationDirectory, name);
const linkDirectory = path.resolve(getDataPath(), "Data", destinationDirectory, name);
if (clean) {
console.log(`Removing link to built package at ${linkDirectory}.`);
await fs.remove(linkDirectory);
} else if (!fs.existsSync(linkDirectory)) {
console.log(`Linking built package to ${linkDirectory}.`);
await fs.ensureDir(path.resolve(linkDirectory, ".."));
await fs.symlink(path.resolve(".", distDirectory), linkDirectory);
}
if (clean) {
console.log(`Removing link to built package at ${linkDirectory}.`);
await fs.remove(linkDirectory);
} else if (!fs.existsSync(linkDirectory)) {
console.log(`Linking built package to ${linkDirectory}.`);
await fs.ensureDir(path.resolve(linkDirectory, ".."));
await fs.symlink(path.resolve(".", distDirectory), linkDirectory);
}
}
const argv = yargs(hideBin(process.argv)).usage("Usage: $0").option("clean", {
alias: "c",
type: "boolean",
default: false,
description: "Remove the link instead of creating it",
alias: "c",
type: "boolean",
default: false,
description: "Remove the link instead of creating it",
}).argv;
const clean = argv.c;
await linkPackage(clean);