Good morning. I'm working on a desktop platform using electron. I'm using the js-yml and writer-yml libraries. The problem I'm having is that with every query or change from these libraries or even opening bootstrap modals the application electron restarts on its own without reporting any errors. This is my main.js code
const electron = require('electron');
const { BrowserWindow, app, dialog, Menu } = electron;
const url = require('url');
const path = require('path');
let TelaInicial;
app.on('ready', () => {
TelaInicial = new BrowserWindow({
width: 800,
height: 600,
minHeight: 600,
minWidth: 800
});
TelaInicial.loadURL(url.format({
pathname: path.join(__dirname, 'config_application_yml.html'),
protocol: 'file:'
}));
});
let menuTemplate = [
{
label: 'File',
submenu: [
{
label: 'Configurar Aplication.yml',
click: () => {
let TelaApplication;
TelaApplication = new BrowserWindow({
width: 800,
height: 600,
minHeight: 600,
minWidth: 800
});
TelaApplication.loadURL(url.format({
pathname: path.join(__dirname, 'config_application_yml.html'),
protocol: 'file:'
}));
}
}, {
label: 'Configurar Application-watchdog.yml',
click: () => {
let TelaApplicationWatchdog;
TelaApplicationWatchdog = new BrowserWindow({
width: 800,
height: 600
});
TelaApplicationWatchdog.loadURL(url.format({
pathname: path.join(__dirname, 'config_application_watchdog_yml.html'),
protocol: 'file:'
}));
}
}
]
}
]
const menu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(menu);
And this is my yml file writing code:
const yaml = require('js-yaml');
const yaml_writer = require('write-yaml');
const fs = require('fs');
function escreverArquivoYML(){
try {
//Base para leitura e escrita em yml
var doc = yaml.safeLoad(fs.readFileSync('application.yml', 'utf8'));
doc.esocial.empregadores[0].codigo = 12345678;
doc.esocial.empregadores[1].codigo = 87654321;
yaml_writer.sync('application.yml', doc);
} catch(e) {
console.log(e);
}
}
Am I doing something wrong that breaks the application so that it will restart like this?