Skip to content

Commit 529a9e4

Browse files
committed
Fix mission file save error caused by fs module usage
Fixes the "fs is not defined" ReferenceError when saving mission files from the Mission Control tab. **Problem:** - Legacy code was using Node.js fs.writeFile() directly from renderer - fs module is not accessible in Electron's renderer process - Users got error: "ReferenceError: fs is not defined" at line 4050 **Solution:** - Replace fs.writeFile() with window.electronAPI.writeFile() - Use Promise-based API (.then) instead of callback pattern - Move success messages inside .then() block to ensure they execute after file write completes **Testing:** - Configurator builds without errors - Mission file save dialog opens correctly - Files save successfully to selected location - No console errors Follows the same pattern used in cli.js and other tabs.
1 parent 1a85fc5 commit 529a9e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tabs/mission_control.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4057,15 +4057,15 @@ function iconKey(filename) {
40574057
var builder = new xml2js.Builder({ 'rootName': 'mission', 'renderOpts': { 'pretty': true, 'indent': '\t', 'newline': '\n' } });
40584058
var xml = builder.buildObject(data);
40594059
xml = xml.replace(/missionitem mission/g, 'meta mission');
4060-
fs.writeFile(filename, xml, (err) => {
4060+
window.electronAPI.writeFile(filename, xml).then(err => {
40614061
if (err) {
40624062
GUI.log(i18n.getMessage('ErrorWritingFile'));
40634063
return console.error(err);
40644064
}
4065+
let sFilename = String(filename.split('\\').pop().split('/').pop());
4066+
GUI.log(sFilename + i18n.getMessage('savedSuccessfully'));
4067+
updateFilename(sFilename);
40654068
});
4066-
let sFilename = String(filename.split('\\').pop().split('/').pop());
4067-
GUI.log(sFilename + i18n.getMessage('savedSuccessfully'));
4068-
updateFilename(sFilename);
40694069
}
40704070

40714071
/////////////////////////////////////////////

0 commit comments

Comments
 (0)