Update validate.js

asynchronous file system operations and provides improved error handling and logging. Additionally, it simplifies file path handling by leveraging path.join.
This commit is contained in:
SenhasD 2024-04-01 23:27:03 +05:30 committed by GitHub
parent 78edeb77c6
commit e37016c191
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 10 deletions

View File

@ -1,18 +1,21 @@
const fs = require("fs");
const fs = require("fs").promises;
const path = require("path");
module.exports = function(dist) {
console.log("");
module.exports = async function checkBuildValidity(dist) {
console.log("Ensuring build validity");
const files = [
path.join(dist, "injector.js"),
path.join(dist, "preload.js"),
path.join(dist, "renderer.js")
"injector.js",
"preload.js",
"renderer.js"
];
for (const file of files) {
const exists = fs.existsSync(file);
if (!exists) throw new Error(` ❌ File missing: ${file}`);
console.log(` ✅ Found ${file}`);
const filePath = path.join(dist, file);
try {
await fs.access(filePath);
console.log(`✅ Found ${filePath}`);
} catch (error) {
throw new Error(`❌ File missing: ${filePath}`);
}
}
};
};