I have FIXED this and it successfully built!
@laurent and @bedwardly-down Thanks for reaching out, but unfortunately, this error/challenge that caused my build to fail was because of the code in joplin-test\joplin\ElectronClient\app\electronRebuild.js
, which was:
const execCommand = function(command) {
const exec = require('child_process').exec;
console.info(`Running: ${command}`);
return new Promise((resolve, reject) => {
exec(command, (error, stdout) => {
if (error) {
if (error.signal == 'SIGTERM') {
resolve('Process was killed');
} else {
reject(error);
}
} else {
resolve(stdout.trim());
}
});
});
};
const isWindows = () => {
return process && process.platform === 'win32';
};
async function main() {
// electron-rebuild --arch ia32 && electron-rebuild --arch x64
let exePath = `${__dirname}/node_modules/.bin/electron-rebuild`;
if (isWindows()) exePath += '.cmd';
if (isWindows()) {
// ---------------Where the problem lies ----------------------------------------------//
console.info(await execCommand([`"${exePath}"`, '--arch ia32'].join(' ')));
console.info(await execCommand([`"${exePath}"`, '--arch x64'].join(' ')));
// -------------------------------------------------------------------------------------------//
} else {
console.info(await execCommand([`"${exePath}"`].join(' ')));
}
}
main().catch((error) => {
console.error(error);
process.exit(1);
});
The code above makes the electron build command to run for both ia32 arch and x64 arch, this is not right, this is what caused my electron-build to fail, because my Windows OS is a x64 arch, it failed because it executed the first command for ia32 arch.
i believe proper way this code should be written is to check for the arch
of the windows os, by using process.arch
and then deciding which electron-build option should be executed instead of just running the two options that has caused frustration for me.
Taking my advice, i modified the joplin-test\joplin\ElectronClient\app\electronRebuild.js
to this and it worked perfectly:
const execCommand = function(command) {
const exec = require('child_process').exec;
console.info(`Running: ${command}`);
return new Promise((resolve, reject) => {
exec(command, (error, stdout) => {
if (error) {
if (error.signal == 'SIGTERM') {
resolve('Process was killed');
} else {
reject(error);
}
} else {
resolve(stdout.trim());
}
});
});
};
const isWindows = () => {
return process && process.platform === 'win32';
};
async function main() {
// electron-rebuild --arch ia32 && electron-rebuild --arch x64
let exePath = `${__dirname}/node_modules/.bin/electron-rebuild`;
if (isWindows()) exePath += '.cmd';
if (isWindows()) {
// -------------- Solution ----------------------------------------------//
process.arch === 'ia32' ? console.info(await execCommand([`"${exePath}"`, '--arch ia32'].join(' '))) : console.info(await execCommand([`"${exePath}"`, '--arch x64'].join(' ')));
// -------------------------------------------------------------------------------------------//
} else {
console.info(await execCommand([`"${exePath}"`].join(' ')));
}
}
main().catch((error) => {
console.error(error);
process.exit(1);
});
Please, lets consider this, i believe this is the best approach to modify that code.