Skip to content
Snippets Groups Projects
Commit 52309db3 authored by Frankly George's avatar Frankly George Committed by Pregmodder
Browse files

Settings menu rework

parent 4608efdf
No related branches found
No related tags found
1 merge request!11858Settings menu rework
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
"javascript->JavaScript", "javascript->JavaScript",
"non-lethal->nonlethal", "non-lethal->nonlethal",
"randomise->randomize", "randomise->randomize",
"seperator->separator",
"slave-owner->slaveowner", "slave-owner->slaveowner",
"slave-owners->slaveowners", "slave-owners->slaveowners",
"slave-ownership->slaveownership", "slave-ownership->slaveownership",
......
...@@ -20,6 +20,8 @@ const args = yargs(hideBin(process.argv)) ...@@ -20,6 +20,8 @@ const args = yargs(hideBin(process.argv))
}) })
.parse(); .parse();
const separatorString = "-".repeat(78);
// default settings // default settings
/** /**
* @typedef {object} Settings * @typedef {object} Settings
...@@ -133,63 +135,189 @@ if (args.settings === true) { ...@@ -133,63 +135,189 @@ if (args.settings === true) {
/** @type {Settings} */ /** @type {Settings} */
let originalSettings = JSON.parse(JSON.stringify(settings)); let originalSettings = JSON.parse(JSON.stringify(settings));
let compilerMenuChoice; const strings = {
compilerMode: () => {
async function compilerSettings() { if (settings.compilerMode === "advanced") {
let choices = []; return "Using the advanced compiler";
if (settings.compilerMode === "advanced") { } else {
choices.push("Using the advanced compiler"); return "Using the simple compiler, change to the advanced compiler for more options";
choices.push(settings.compileThemes }
},
compileThemes: () => {
return (settings.compileThemes
? "Themes are compiled" ? "Themes are compiled"
: "Themes are not compiled" : "Themes are not compiled"
); );
choices.push(settings.compilerSourcemaps },
compilerSourcemaps: () => {
return (settings.compilerSourcemaps
? "Source maps are added, minification is disabled" ? "Source maps are added, minification is disabled"
: "Source maps are not added" : "Source maps are not added"
); );
if (settings.compilerSourcemaps === false) { },
choices.push(settings.compilerMinify compilerMinify: () => {
? "Build is minified" return (settings.compilerMinify
: "Build is not minified" ? "Build is minified"
); : "Build is not minified"
} );
choices.push(settings.compilerAddDebugFiles },
compilerAddDebugFiles: () => {
return (settings.compilerAddDebugFiles
? "Adding *.debug.* files to the build" ? "Adding *.debug.* files to the build"
: "Ignoring *.debug.* files" : "Ignoring *.debug.* files"
); );
if (settings.compilerRunSanityChecks === 0) { },
choices.push("Not running sanity checks when compiling"); compilerFilenameHash: () => {
} else if (settings.compilerRunSanityChecks === 1) { return (settings.compilerFilenameHash
choices.push("Running sanity checks before compiling");
} else {
choices.push("Running sanity checks after compiling");
}
choices.push(settings.compilerFilenameHash
? "Adding the current Git commit hash to the final filename" ? "Adding the current Git commit hash to the final filename"
: "Not adding the current Git commit hash to the final filename" : "Not adding the current Git commit hash to the final filename"
); );
choices.push(settings.compilerFilenameEpoch },
compilerFilenameEpoch: () => {
return (settings.compilerFilenameEpoch
? "Adding the current time to the final filename" ? "Adding the current time to the final filename"
: "Not adding the current time to the final filename" : "Not adding the current time to the final filename"
); );
choices.push(settings.compilerFilenamePmodVersion },
compilerFilenamePmodVersion: () => {
return (settings.compilerFilenamePmodVersion
? "Adding the current Pmod version to the final filename" ? "Adding the current Pmod version to the final filename"
: "Not adding the current Pmod version to the final filename" : "Not adding the current Pmod version to the final filename"
); );
choices.push(`Verbosity level: ${settings.compilerVerbosity}`); },
choices.push(settings.compilerCopyToFCHost compilerVerbosity: () => {
? "Copying compiled files to FCHost's directory" return `Verbosity level: ${settings.compilerVerbosity}`;
: "Not copying compiled files to FCHost's directory" },
compilerRunSanityChecks: () => {
if (settings.compilerRunSanityChecks === 0) {
return "Not running sanity checks when compiling";
} else if (settings.compilerRunSanityChecks === 1) {
return "Running sanity checks before compiling";
} else {
return "Running sanity checks after compiling";
}
},
compilerWaitOnWindows: () => {
return (settings.compilerWaitOnWindows
? "Waiting for user input before exiting compiler"
: "Exiting compiler without user input"
); );
} else if (settings.compilerMode === "simple") { },
choices.push("Using the simple compiler, change to the advanced compiler for more options"); precommitHookEnabled: () => {
choices.push(settings.compileThemes if (settings.precommitHookEnabled === 0) {
? "Themes are compiled" return "Not running sanity checks before commiting";
: "Themes are not compiled" } else if (settings.precommitHookEnabled === 1) {
return "Running sanity checks before commiting";
} else {
return "Sanity checks are temporarily disabled and will be re-enabled after the next commit";
}
},
checksEnableCustom: () => {
return (settings.checksEnableCustom
? "Custom sanity checks are enabled"
: "Custom sanity checks are disabled"
);
},
checksEnableSpelling: () => {
return (settings.checksEnableSpelling
? "Spelling checks are enabled"
: "Spelling checks are disabled"
);
},
checksEnableESLint: () => {
return (settings.checksEnableESLint
? "JavaScript linting is enabled"
: "JavaScript linting is disabled"
);
},
checksEnableTypescript: () => {
return (settings.checksEnableTypescript
? "JavaScript type checking is enabled"
: "JavaScript type checking is disabled"
);
},
checksOnlyChangedCustom: () => {
return (settings.checksOnlyChangedCustom
? "Custom sanity checks are only reporting problems on changed lines"
: "Custom sanity checks are reporting all problems"
);
},
checksOnlyChangedSpelling: () => {
return (settings.checksOnlyChangedSpelling
? "Spelling checks are only reporting problems on changed lines"
: "Spelling checks are reporting all problems"
);
},
checksOnlyChangedESLint: () => {
return (settings.checksOnlyChangedESLint
? "JavaScript linting is only reporting problems on changed lines"
: "JavaScript linting is reporting all problems"
); );
},
checksOnlyChangedTypescript: () => {
return (settings.checksOnlyChangedTypescript
? "JavaScript type checking is only reporting problems on changed lines"
: "JavaScript type checking is reporting all problems"
);
},
manageNodePackages: () => {
if (settings.manageNodePackages === -1) {
return "Ignoring incorrect Node packages";
} else if (settings.manageNodePackages === 0) {
return "Asking about incorrect Node packages";
} else {
return "Automatically fixing incorrect Node packages";
}
},
fetchUpstreamBranch: () => {
if (settings.fetchUpstreamBranch === -1) {
return "Not fetching upstream pregmod-master branch. Sanity checks will report all errors";
} else if (settings.fetchUpstreamBranch === 0) {
return "Asking before fetching upstream pregmod-master branch";
} else {
return "Automatically pulling upstream pregmod-master branch. Sanity checks can report changed lines";
}
},
WatcherLiveReload: () => {
return (settings.WatcherLiveReload
? "Watcher is triggering a live reload on each successful build"
: "Watcher is not triggering a live reload on each successful build"
);
},
compilerCopyToFCHost: () => {
return (settings.compilerCopyToFCHost
? "Copying FC to FCHost's directory after a successful build"
: "Not copying FC to FCHost's directory"
);
},
};
let compilerMenuChoice;
async function compilerSettings() {
let choices = [];
if (settings.compilerMode === "advanced") {
choices.push(strings.compilerMode());
choices.push(new inquirer.Separator(separatorString));
choices.push(strings.compileThemes());
choices.push(strings.compilerSourcemaps());
if (settings.compilerSourcemaps === false) {
choices.push(strings.compilerMinify());
}
choices.push(strings.compilerAddDebugFiles());
choices.push(strings.compilerFilenameHash());
choices.push(strings.compilerFilenameEpoch());
choices.push(strings.compilerFilenamePmodVersion());
choices.push(strings.compilerVerbosity());
choices.push(new inquirer.Separator(separatorString));
choices.push(strings.compilerRunSanityChecks());
} else {
choices.push(strings.compilerMode());
choices.push(new inquirer.Separator(separatorString));
choices.push(strings.compileThemes());
} }
if (process.platform === "win32") { if (process.platform === "win32") {
choices.push(settings.compilerWaitOnWindows ? "Waiting for user input before exiting compiler" : "Exiting compiler without user input"); choices.push(strings.compilerWaitOnWindows());
} }
choices.push("Back"); choices.push("Back");
...@@ -208,86 +336,61 @@ async function compilerSettings() { ...@@ -208,86 +336,61 @@ async function compilerSettings() {
compilerMenuChoice = answers.choice; compilerMenuChoice = answers.choice;
}); });
if ( if (compilerMenuChoice === strings.compilerMode()) {
compilerMenuChoice === "Using the advanced compiler" ||
compilerMenuChoice === "Using the simple compiler, change to the advanced compiler for more options"
) {
if (settings.compilerMode === "simple") { if (settings.compilerMode === "simple") {
settings.compilerMode = "advanced"; settings.compilerMode = "advanced";
} else { } else {
settings.compilerMode = "simple"; settings.compilerMode = "simple";
} }
} else if ( compilerMenuChoice = strings.compilerMode();
compilerMenuChoice === "Themes are compiled" || } else if (compilerMenuChoice === strings.compileThemes()) {
compilerMenuChoice === "Themes are not compiled"
) {
settings.compileThemes = !settings.compileThemes; settings.compileThemes = !settings.compileThemes;
} else if ( compilerMenuChoice = strings.compileThemes();
compilerMenuChoice === "Source maps are added, minification is disabled" || } else if (compilerMenuChoice === strings.compilerSourcemaps()) {
compilerMenuChoice === "Source maps are not added"
) {
settings.compilerSourcemaps = !settings.compilerSourcemaps; settings.compilerSourcemaps = !settings.compilerSourcemaps;
if (settings.compilerSourcemaps === true) { if (settings.compilerSourcemaps === true) {
settings.compilerMinify = false; settings.compilerMinify = false;
} }
} else if ( compilerMenuChoice = strings.compilerSourcemaps();
compilerMenuChoice === "Build is minified" || } else if (compilerMenuChoice === strings.compilerMinify()) {
compilerMenuChoice === "Build is not minified"
) {
settings.compilerMinify = !settings.compilerMinify; settings.compilerMinify = !settings.compilerMinify;
} else if ( compilerMenuChoice = strings.compilerMinify();
compilerMenuChoice === "Adding *.debug.* files to the build" || } else if (compilerMenuChoice === strings.compilerAddDebugFiles()) {
compilerMenuChoice === "Ignoring *.debug.* files"
) {
settings.compilerAddDebugFiles = !settings.compilerAddDebugFiles; settings.compilerAddDebugFiles = !settings.compilerAddDebugFiles;
} else if ( compilerMenuChoice = strings.compilerAddDebugFiles();
compilerMenuChoice === "Not running sanity checks when compiling" || } else if (compilerMenuChoice === strings.compilerFilenameHash()) {
compilerMenuChoice === "Running sanity checks before compiling" ||
compilerMenuChoice === "Running sanity checks after compiling"
) {
if (settings.compilerRunSanityChecks === 2) {
settings.compilerRunSanityChecks = 0;
} else {
settings.compilerRunSanityChecks += 1;
}
} else if (
compilerMenuChoice === "Adding the current Git commit hash to the final filename" ||
compilerMenuChoice === "Not adding the current Git commit hash to the final filename"
) {
settings.compilerFilenameHash = !settings.compilerFilenameHash; settings.compilerFilenameHash = !settings.compilerFilenameHash;
} else if ( compilerMenuChoice = strings.compilerFilenameHash();
compilerMenuChoice === "Adding the current time to the final filename" || } else if (compilerMenuChoice === strings.compilerFilenameEpoch()) {
compilerMenuChoice === "Not adding the current time to the final filename"
) {
settings.compilerFilenameEpoch = !settings.compilerFilenameEpoch; settings.compilerFilenameEpoch = !settings.compilerFilenameEpoch;
} else if ( compilerMenuChoice = strings.compilerFilenameEpoch();
compilerMenuChoice === "Adding the current Pmod version to the final filename" || } else if (compilerMenuChoice === strings.compilerFilenamePmodVersion()) {
compilerMenuChoice === "Not adding the current Pmod version to the final filename"
) {
settings.compilerFilenamePmodVersion = !settings.compilerFilenamePmodVersion; settings.compilerFilenamePmodVersion = !settings.compilerFilenamePmodVersion;
} else if (compilerMenuChoice === `Verbosity level: ${settings.compilerVerbosity}`) { compilerMenuChoice = strings.compilerFilenamePmodVersion();
} else if (compilerMenuChoice === strings.compilerVerbosity()) {
if (settings.compilerVerbosity === 6) { if (settings.compilerVerbosity === 6) {
settings.compilerVerbosity = 1; settings.compilerVerbosity = 1;
} else { } else {
settings.compilerVerbosity += 1; settings.compilerVerbosity += 1;
} }
} else if ( compilerMenuChoice = strings.compilerVerbosity();
compilerMenuChoice === "Copying compiled files to FCHost's directory" || } else if (compilerMenuChoice === strings.compilerRunSanityChecks()) {
compilerMenuChoice === "Not copying compiled files to FCHost's directory" if (settings.compilerRunSanityChecks === 2) {
) { settings.compilerRunSanityChecks = 0;
settings.compilerCopyToFCHost = !settings.compilerCopyToFCHost; } else {
} else if ( settings.compilerRunSanityChecks += 1;
compilerMenuChoice === "Waiting for user input before exiting compiler" || }
compilerMenuChoice === "Exiting compiler without user input" compilerMenuChoice = strings.compilerRunSanityChecks();
) { } else if (compilerMenuChoice === strings.compilerWaitOnWindows()) {
settings.compilerWaitOnWindows = !settings.compilerWaitOnWindows; settings.compilerWaitOnWindows = !settings.compilerWaitOnWindows;
compilerMenuChoice = strings.compilerWaitOnWindows();
} else if (compilerMenuChoice === "Back") { } else if (compilerMenuChoice === "Back") {
compilerMenuChoice = 0; compilerMenuChoice = 0;
return; return;
} else {
throw new Error("Invalid compiler menu choice: " + compilerMenuChoice);
} }
compilerMenuChoice = choices.indexOf(compilerMenuChoice);
await compilerSettings(); await compilerSettings();
} }
...@@ -295,59 +398,25 @@ let sanityCheckMenuChoice; ...@@ -295,59 +398,25 @@ let sanityCheckMenuChoice;
async function sanityCheckSettings() { async function sanityCheckSettings() {
let choices = []; let choices = [];
if (settings.precommitHookEnabled === 0) { choices.push(strings.precommitHookEnabled());
choices.push("Not running sanity checks before commiting"); choices.push(strings.compilerRunSanityChecks());
} else if (settings.precommitHookEnabled === 1) { choices.push(new inquirer.Separator(separatorString));
choices.push("Running sanity checks before commiting"); choices.push(strings.checksEnableCustom());
} else { choices.push(strings.checksEnableSpelling());
choices.push("Sanity checks are temporarily disabled and will be re-enabled after the next commit"); choices.push(strings.checksEnableESLint());
} choices.push(strings.checksEnableTypescript());
if (settings.compilerRunSanityChecks === 0) { choices.push(new inquirer.Separator(separatorString));
choices.push("Not running sanity checks when compiling");
} else if (settings.compilerRunSanityChecks === 1) {
choices.push("Running sanity checks before compiling");
} else {
choices.push("Running sanity checks after compiling");
}
choices.push(settings.checksEnableCustom
? "Custom sanity checks are enabled"
: "Custom sanity checks are disabled"
);
choices.push(settings.checksEnableSpelling
? "Spelling checks are enabled"
: "Spelling checks are disabled"
);
choices.push(settings.checksEnableESLint
? "JavaScript linting is enabled"
: "JavaScript linting is disabled"
);
choices.push(settings.checksEnableTypescript
? "JavaScript type checking is enabled"
: "JavaScript type checking is disabled"
);
if (settings.checksEnableCustom === true) { if (settings.checksEnableCustom === true) {
choices.push(settings.checksOnlyChangedCustom choices.push(strings.checksOnlyChangedCustom());
? "Custom sanity checks are only reporting problems on changed lines"
: "Custom sanity checks are reporting all problems"
);
} }
if (settings.checksEnableSpelling === true) { if (settings.checksEnableSpelling === true) {
choices.push(settings.checksOnlyChangedSpelling choices.push(strings.checksOnlyChangedSpelling());
? "Spelling checks are only reporting problems on changed lines"
: "Spelling checks are reporting all problems"
);
} }
if (settings.checksEnableESLint === true) { if (settings.checksEnableESLint === true) {
choices.push(settings.checksOnlyChangedESLint choices.push(strings.checksOnlyChangedESLint());
? "JavaScript linting is only reporting problems on changed lines"
: "JavaScript linting is reporting all problems"
);
} }
if (settings.checksEnableTypescript === true) { if (settings.checksEnableTypescript === true) {
choices.push(settings.checksOnlyChangedTypescript choices.push(strings.checksOnlyChangedTypescript());
? "JavaScript type checking is only reporting problems on changed lines"
: "JavaScript type checking is reporting all problems"
);
} }
choices.push("Back"); choices.push("Back");
...@@ -365,11 +434,7 @@ async function sanityCheckSettings() { ...@@ -365,11 +434,7 @@ async function sanityCheckSettings() {
.then((answers) => { .then((answers) => {
sanityCheckMenuChoice = answers.choice; sanityCheckMenuChoice = answers.choice;
}); });
if ( if (sanityCheckMenuChoice === strings.precommitHookEnabled()) {
sanityCheckMenuChoice === "Running sanity checks before commiting" ||
sanityCheckMenuChoice === "Not running sanity checks before commiting" ||
sanityCheckMenuChoice === "Sanity checks are temporarily disabled and will be re-enabled after the next commit"
) {
if (settings.precommitHookEnabled === -1) { if (settings.precommitHookEnabled === -1) {
settings.precommitHookEnabled = 0; settings.precommitHookEnabled = 0;
} else if (settings.precommitHookEnabled === 0) { } else if (settings.precommitHookEnabled === 0) {
...@@ -377,91 +442,59 @@ async function sanityCheckSettings() { ...@@ -377,91 +442,59 @@ async function sanityCheckSettings() {
} else { } else {
settings.precommitHookEnabled = -1; settings.precommitHookEnabled = -1;
} }
} else if ( sanityCheckMenuChoice = strings.precommitHookEnabled();
sanityCheckMenuChoice === "Not running sanity checks when compiling" || } else if (sanityCheckMenuChoice === strings.compilerRunSanityChecks()) {
sanityCheckMenuChoice === "Running sanity checks before compiling" ||
sanityCheckMenuChoice === "Running sanity checks after compiling"
) {
if (settings.compilerRunSanityChecks === 2) { if (settings.compilerRunSanityChecks === 2) {
settings.compilerRunSanityChecks = 0; settings.compilerRunSanityChecks = 0;
} else { } else {
settings.compilerRunSanityChecks += 1; settings.compilerRunSanityChecks += 1;
} }
} else if ( sanityCheckMenuChoice = strings.compilerRunSanityChecks();
sanityCheckMenuChoice === "Custom sanity checks are enabled" || } else if (sanityCheckMenuChoice === strings.checksEnableCustom()) {
sanityCheckMenuChoice === "Custom sanity checks are disabled"
) {
settings.checksEnableCustom = !settings.checksEnableCustom; settings.checksEnableCustom = !settings.checksEnableCustom;
} else if ( sanityCheckMenuChoice = strings.checksEnableCustom();
sanityCheckMenuChoice === "Spelling checks are enabled" || } else if (sanityCheckMenuChoice === strings.checksEnableSpelling()) {
sanityCheckMenuChoice === "Spelling checks are disabled"
) {
settings.checksEnableSpelling = !settings.checksEnableSpelling; settings.checksEnableSpelling = !settings.checksEnableSpelling;
} else if ( sanityCheckMenuChoice = strings.checksEnableSpelling();
sanityCheckMenuChoice === "JavaScript linting is enabled" || } else if (sanityCheckMenuChoice === strings.checksEnableESLint()) {
sanityCheckMenuChoice === "JavaScript linting is disabled"
) {
settings.checksEnableESLint = !settings.checksEnableESLint; settings.checksEnableESLint = !settings.checksEnableESLint;
} else if ( sanityCheckMenuChoice = strings.checksEnableESLint();
sanityCheckMenuChoice === "JavaScript type checking is enabled" || } else if (sanityCheckMenuChoice === strings.checksEnableTypescript()) {
sanityCheckMenuChoice === "JavaScript type checking is disabled"
) {
settings.checksEnableTypescript = !settings.checksEnableTypescript; settings.checksEnableTypescript = !settings.checksEnableTypescript;
} else if ( sanityCheckMenuChoice = strings.checksEnableTypescript();
sanityCheckMenuChoice === "Custom sanity checks are only reporting problems on changed lines" || } else if (sanityCheckMenuChoice === strings.checksOnlyChangedCustom()) {
sanityCheckMenuChoice === "Custom sanity checks are reporting all problems"
) {
settings.checksOnlyChangedCustom = !settings.checksOnlyChangedCustom; settings.checksOnlyChangedCustom = !settings.checksOnlyChangedCustom;
} else if ( sanityCheckMenuChoice = strings.checksOnlyChangedCustom();
sanityCheckMenuChoice === "Spelling checks are only reporting problems on changed lines" || } else if (sanityCheckMenuChoice === strings.checksOnlyChangedSpelling()) {
sanityCheckMenuChoice === "Spelling checks are reporting all problems"
) {
settings.checksOnlyChangedSpelling = !settings.checksOnlyChangedSpelling; settings.checksOnlyChangedSpelling = !settings.checksOnlyChangedSpelling;
} else if ( sanityCheckMenuChoice = strings.checksOnlyChangedSpelling();
sanityCheckMenuChoice === "JavaScript linting is only reporting problems on changed lines" || } else if (sanityCheckMenuChoice === strings.checksOnlyChangedESLint()) {
sanityCheckMenuChoice === "JavaScript linting is reporting all problems"
) {
settings.checksOnlyChangedESLint = !settings.checksOnlyChangedESLint; settings.checksOnlyChangedESLint = !settings.checksOnlyChangedESLint;
} else if ( sanityCheckMenuChoice = strings.checksOnlyChangedESLint();
sanityCheckMenuChoice === "JavaScript type checking is only reporting problems on changed lines" || } else if (sanityCheckMenuChoice === strings.checksOnlyChangedTypescript()) {
sanityCheckMenuChoice === "JavaScript type checking is reporting all problems"
) {
settings.checksOnlyChangedTypescript = !settings.checksOnlyChangedTypescript; settings.checksOnlyChangedTypescript = !settings.checksOnlyChangedTypescript;
sanityCheckMenuChoice = strings.checksOnlyChangedTypescript();
} else if ( } else if (
sanityCheckMenuChoice === "Back" sanityCheckMenuChoice === "Back"
) { ) {
sanityCheckMenuChoice = 0; sanityCheckMenuChoice = 0;
return; return;
} else {
throw new Error("Invalid sanity check menu choice: " + sanityCheckMenuChoice);
} }
sanityCheckMenuChoice = choices.indexOf(sanityCheckMenuChoice);
await sanityCheckSettings(); await sanityCheckSettings();
} }
let MiscMenuChoice; let miscMenuChoice;
async function MiscSettings() { async function MiscSettings() {
let choices = []; let choices = [];
if (settings.manageNodePackages === -1) { choices.push(strings.manageNodePackages());
choices.push("Ignoring incorrect Node packages"); choices.push(strings.fetchUpstreamBranch());
} else if (settings.manageNodePackages === 0) { choices.push(new inquirer.Separator(separatorString));
choices.push("Asking about incorrect Node packages"); choices.push(strings.WatcherLiveReload());
} else { choices.push(strings.compilerCopyToFCHost());
choices.push("Automatically fixing incorrect Node packages");
}
if (settings.fetchUpstreamBranch === -1) {
choices.push("Not fetching upstream pregmod-master branch. Sanity checks will report all errors");
} else if (settings.fetchUpstreamBranch === 0) {
choices.push("Asking before fetching upstream pregmod-master branch");
} else {
choices.push("Automatically pulling upstream pregmod-master branch. Sanity checks can report changed lines");
}
choices.push(settings.WatcherLiveReload
? "Watcher is triggering a live reload on each successful build"
: "Watcher is not triggering a live reload on each successful build"
);
choices.push("Back"); choices.push("Back");
await inquirer await inquirer
...@@ -470,45 +503,41 @@ async function MiscSettings() { ...@@ -470,45 +503,41 @@ async function MiscSettings() {
name: "choice", name: "choice",
message: "Miscellaneous Settings", message: "Miscellaneous Settings",
choices: choices, choices: choices,
default: MiscMenuChoice, default: miscMenuChoice,
loop: false, loop: false,
pageSize: 11 pageSize: 11
}]) }])
.then((answers) => { .then((answers) => {
MiscMenuChoice = answers.choice; miscMenuChoice = answers.choice;
}); });
if ( if (miscMenuChoice === strings.manageNodePackages()) {
MiscMenuChoice === "Ignoring incorrect Node packages" ||
MiscMenuChoice === "Asking about incorrect Node packages" ||
MiscMenuChoice === "Automatically fixing incorrect Node packages"
) {
if (settings.manageNodePackages === 1) { if (settings.manageNodePackages === 1) {
settings.manageNodePackages = -1; settings.manageNodePackages = -1;
} else { } else {
settings.manageNodePackages += 1; settings.manageNodePackages += 1;
} }
} else if ( miscMenuChoice = strings.manageNodePackages();
MiscMenuChoice === "Not fetching upstream pregmod-master branch. Sanity checks will report all errors" || } else if (miscMenuChoice === strings.fetchUpstreamBranch()) {
MiscMenuChoice === "Asking before fetching upstream pregmod-master branch" ||
MiscMenuChoice === "Automatically pulling upstream pregmod-master branch. Sanity checks can report changed lines"
) {
if (settings.fetchUpstreamBranch === 1) { if (settings.fetchUpstreamBranch === 1) {
settings.fetchUpstreamBranch = -1; settings.fetchUpstreamBranch = -1;
} else { } else {
settings.fetchUpstreamBranch += 1; settings.fetchUpstreamBranch += 1;
} }
} else if ( miscMenuChoice = strings.fetchUpstreamBranch();
MiscMenuChoice === "Watcher is triggering a live reload on each successful build" || } else if (miscMenuChoice === strings.WatcherLiveReload()) {
MiscMenuChoice === "Watcher is not triggering a live reload on each successful build"
) {
settings.WatcherLiveReload = !settings.WatcherLiveReload; settings.WatcherLiveReload = !settings.WatcherLiveReload;
} else if (MiscMenuChoice === "Back") { miscMenuChoice = strings.WatcherLiveReload();
} else if (miscMenuChoice === strings.compilerCopyToFCHost()) {
settings.compilerCopyToFCHost = !settings.compilerCopyToFCHost;
miscMenuChoice = strings.compilerCopyToFCHost();
} else if (miscMenuChoice === "Back") {
miscMenuChoice = 0;
return; return;
} else {
throw new Error("Invalid misc menu choice: " + miscMenuChoice);
} }
MiscMenuChoice = choices.indexOf(MiscMenuChoice);
await MiscSettings(); await MiscSettings();
} }
...@@ -555,6 +584,8 @@ async function mainMenu() { ...@@ -555,6 +584,8 @@ async function mainMenu() {
mainMenuChoice === "Exit" mainMenuChoice === "Exit"
) { ) {
process.exit(0); process.exit(0);
} else {
throw new Error("Invalid main menu choice: " + mainMenuChoice);
} }
mainMenuChoice = choices.indexOf(mainMenuChoice); mainMenuChoice = choices.indexOf(mainMenuChoice);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment