New shutdown script for cross-platform ease of use; implement host option in config file; minor code cleanup.

This commit is contained in:
00Fjongl 2024-08-07 10:10:19 -05:00
parent c21d775ee8
commit 92909e4ab7
7 changed files with 59 additions and 10 deletions

View file

@ -1,7 +1,13 @@
import { readFile } from 'node:fs/promises';
// Parse the config file to grab a property value from it.
let property = JSON.parse(await readFile(new URL("./src/config.json", import.meta.url)));
// Combine all descriptors (from command line arguments) to get the property value.
process.argv.slice(2).forEach(descriptor => {property = property[descriptor]});
// Return a boolean if it's true or false.
if (typeof property === "boolean") process.exitCode = +!property;
// Otherwise, return a stringified version to the stream.
else {
console.log(property);
process.exitCode = 0;