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:
parent
78edeb77c6
commit
e37016c191
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue