diff --git a/devTools/scripts/advancedCompiler.js b/devTools/scripts/advancedCompiler.js index 19b0c0ad59bc4bdcbc59c74012e729d468d6bc9b..0eadef0df4fbbe0027dac382da2f58a8aa7ceeb3 100644 --- a/devTools/scripts/advancedCompiler.js +++ b/devTools/scripts/advancedCompiler.js @@ -7,6 +7,7 @@ import {execSync} from "child_process"; // @ts-ignore import jetpack from "fs-jetpack"; +import * as path from "path"; import yargs from "yargs"; import {hideBin} from "yargs/helpers"; @@ -83,13 +84,44 @@ if (settings.compilerMode === "simple") { if (settings.compilerFilenamePmodVersion === true) { command += ` --pmodversion`; } - command += ` --filename=${args.filename}` + command += ` --filename=${args.filename}`; } console.log(`Executing "${command}"`); execSync(command, {stdio: "inherit"}); +if (settings.compilerCopyToFCHost === true) { + if (jetpack.exists(settings.FCHostPath) === "dir") { + console.log(`Copying files from "bin" to "${settings.FCHostPath}"`); + // for each file/folder in bin + jetpack.list("bin").forEach(fPath => { + // if path doesn't end with .html + if (!fPath.endsWith(".html")) { + // copy it to FCHostPath, overwritting the existing file + jetpack.copy( + path.join("bin", fPath), + path.join(settings.FCHostPath, fPath), + {overwrite: true} + ); + } + }); + // copy output html file to FCHostPath, renaming it to FC_pregmod.html + const htmlPath = path.join("bin", args.filename); + if (jetpack.exists(htmlPath) === "file") { + jetpack.copy( + htmlPath, + path.join(settings.FCHostPath, "FC_pregmod.html"), + {overwrite: true} + ); + } else { + console.log(`Couldn't find "${htmlPath}"!`); + } + } else { + console.log(`Skipping: 'Copy "bin" to "${settings.FCHostPath}"' because the path doesn't exist`); + } +} + if (settings.compilerMode === "advanced" && settings.compilerRunSanityChecks === 2) { try { execSync( diff --git a/devTools/scripts/setup.js b/devTools/scripts/setup.js index 8d4efa59adf2a15b0ec9f8e2d1228ee4dbaf2407..43d52ff6cc2da6e8f1b1c281cc23556f5c94aa91 100644 --- a/devTools/scripts/setup.js +++ b/devTools/scripts/setup.js @@ -3,6 +3,7 @@ */ // cSpell:words list +// cSpell:ignore fchost import yargs from "yargs"; import {hideBin} from "yargs/helpers"; @@ -35,6 +36,7 @@ const args = yargs(hideBin(process.argv)) * @property {boolean} compilerFilenameEpoch If true then tell the advanced compiler to add the current epoch to the filename * @property {boolean} compilerFilenamePmodVersion If true then tell the advanced compiler to add the current pmod version to the filename * @property {0|1|2} compilerRunSanityChecks 0 = Do not run sanity checks during compiling, 1 = Run before compiling, 2 = Run after compiling + * @property {boolean} compilerCopyToFCHost If true copy files from "bin" to settings.FCHostPath * @property {boolean} checksEnableCustom If true then we will run Extra sanity checks * @property {boolean} checksOnlyChangedCustom If true then we will only check changed lines * @property {boolean} checksEnableSpelling If true then we will run Spelling checks @@ -44,9 +46,9 @@ const args = yargs(hideBin(process.argv)) * @property {boolean} checksEnableTypescript If true then we will run Typescript checks * @property {boolean} checksOnlyChangedTypescript If true then we will only check changed lines * @property {-1|0|1} precommitHookEnabled 0 = Disabled, 1 = Enabled, -1 = temporarily disabled + * @property {string} FCHostPath Path to FCHost's directory */ -// TODO:@franklygeorge Write watcher.[bat,sh,js] // TODO:@franklygeorge Do we want an extensions.json file for VSCode? // TODO:@franklygeorge Figure out why setup.[bat,sh] is slow to start (~5 seconds). Probably affects compile.[bat,sh] and sanityCheck.[bat,sh] as well // TODO:@franklygeorge Search for todo's with @franklygeorge in them and complete them @@ -66,6 +68,7 @@ const settings = { compilerFilenameEpoch: false, compilerFilenamePmodVersion: false, compilerRunSanityChecks: 0, + compilerCopyToFCHost: true, checksEnableCustom: true, checksOnlyChangedCustom: true, checksEnableSpelling: true, @@ -75,6 +78,7 @@ const settings = { checksEnableTypescript: false, checksOnlyChangedTypescript: true, precommitHookEnabled: 1, + FCHostPath: "FCHost/fchost/Release", }; // create settings.json if it doesn't exist @@ -171,6 +175,10 @@ async function compilerSettings() { : "Not adding the current Pmod version to the final filename" ); choices.push(`Verbosity level: ${settings.compilerVerbosity}`); + choices.push(settings.compilerCopyToFCHost + ? "Copying compiled files to FCHost's directory" + : "Not copying compiled files to FCHost's directory" + ); } else if (settings.compilerMode === "simple") { choices.push("Using the simple compiler, change to the advanced compiler for more options"); choices.push(settings.compileThemes @@ -261,6 +269,11 @@ async function compilerSettings() { } else { settings.compilerVerbosity += 1; } + } else if ( + compilerMenuChoice === "Copying compiled files to FCHost's directory" || + compilerMenuChoice === "Not copying compiled files to FCHost's directory" + ) { + settings.compilerCopyToFCHost = !settings.compilerCopyToFCHost; } else if ( compilerMenuChoice === "Waiting for user input before exiting compiler" || compilerMenuChoice === "Exiting compiler without user input"