Refactor scripts to meet ES2020 compliance.

This commit is contained in:
Michael Green 2025-12-18 10:43:45 +11:00
parent 200fa5a4e9
commit 21b83ca54d
5 changed files with 42 additions and 37 deletions

View File

@ -23,4 +23,4 @@ jobs:
run: npm install
- name: Run ESLint
run: npx eslint . --max-warnings 0
run: npx eslint .

View File

@ -99,14 +99,15 @@ if (!build_type) {
return JSON.parse(fs.readFileSync(coresJsonPath, 'utf8'));
};
if (build_type === "emulatorjs") {
console.log(`Current EmulatorJS Version: ${version}`);
removeLogo();
console.log("Ready to build EmulatorJS!");
} else if (build_type === "get-cores") {
const cores = await getCores();
console.log(JSON.stringify(cores.map(coreName => coreName.name)));
} else if (build_type === "cores") {
const main = async () => {
if (build_type === "emulatorjs") {
console.log(`Current EmulatorJS Version: ${version}`);
removeLogo();
console.log("Ready to build EmulatorJS!");
} else if (build_type === "get-cores") {
const cores = await getCores();
console.log(JSON.stringify(cores.map(coreName => coreName.name)));
} else if (build_type === "cores") {
console.log(`Current EmulatorJS Version: ${version}`);
console.log("Building cores...");
const allCores = await getCores();
@ -177,7 +178,10 @@ if (!build_type) {
packageJson.dependencies[`@emulatorjs/core-${core}`] = "latest";
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
}
console.log("EmulatorJS cores built successfully!");
console.log("Ready to build EmulatorJS!");
}
console.log("EmulatorJS cores built successfully!");
console.log("Ready to build EmulatorJS!");
}
};
main();
}

View File

@ -1,7 +1,4 @@
class GamepadHandler {
gamepads;
timeout;
listeners;
constructor() {
this.buttonLabels = {
0: 'BUTTON_1',

View File

@ -14,10 +14,10 @@ async function doMinify() {
input: path.join(rootPath, "data/src/*.js"),
output: path.join(rootPath, "data/emulator.min.js"),
})
.catch(function (err) {
.catch((err) => {
console.error(err);
})
.then(function() {
.then(() => {
console.log("Minified JS");
});
await minify({
@ -25,14 +25,16 @@ async function doMinify() {
input: path.join(rootPath, "data/emulator.css"),
output: path.join(rootPath, "data/emulator.min.css"),
})
.catch(function (err) {
.catch((err) => {
console.error(err);
})
.then(function() {
.then(() => {
console.log("Minified CSS");
});
}
console.log("Minifying");
await doMinify();
console.log("Minifying Done!");
(async () => {
await doMinify();
console.log("Minifying Done!");
})();

View File

@ -116,20 +116,22 @@ const updateContributors = async () => {
console.log("Updated Contributors.md with new contributors.");
}
console.log(`Current EmulatorJS Version: ${version}`);
if (!update_version) {
console.warn("Warning: Version number not provided.");
} else {
console.log(`Updating EmulatorJS Version number to: ${update_version}`);
}
(async () => {
console.log(`Current EmulatorJS Version: ${version}`);
if (!update_version) {
console.warn("Warning: Version number not provided.");
} else {
console.log(`Updating EmulatorJS Version number to: ${update_version}`);
}
console.log("Updating EmulatorJS dependencies...");
if (depsArg) {
await updateDependencies();
}
if (update_version || dev === "false" || dev === "true") {
console.log("Updating EmulatorJS version...");
await updateVersion(update_version || version);
}
await updateContributors();
console.log("Updating EmulatorJS completed.");
console.log("Updating EmulatorJS dependencies...");
if (depsArg) {
await updateDependencies();
}
if (update_version || dev === "false" || dev === "true") {
console.log("Updating EmulatorJS version...");
await updateVersion(update_version || version);
}
await updateContributors();
console.log("Updating EmulatorJS completed.");
})();