Cannot select files after moving app to prebuilt binary for distribution

I am using a drop into a field to retrieve the path of a file. I also tried using a button and a dialog to do the same. It works fine when I run the app with NPM start. But as soon as I move the files into the binary to distribute the app, it stops working. The button does not open the dialog anymore and nothing happens when I drop the file into the field.

Please note I am NOT a javascript coder, this is an app to support some embedded stuff I am making. Sorry for the mess.

If anybody has an idea, thanks in advance!! It’s really a bummer it stopped working after distributing the app…

Here is the script file :

var firmware_path;

var app = require('electron').remote;
var dialog = app.dialog;
var fs = require('fs'); // Load the File System to execute our common tasks (CRUD)

var start_printing = 0;

var app = require('electron').remote;
var dialog = app.dialog;

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

window.onload = function () {
  console.log("App starting");
};

document.addEventListener('drop', function (e) {
  e.preventDefault();
  e.stopPropagation();

  for (let f of e.dataTransfer.files) {
    console.log('File(s) you dragged here: ', f.path)
    f.path = "/Users/nicolastoussaint/Desktop/upload_tool_test_USB/SFC_1_V1.0.ino.bin";

    document.getElementById("droid-output").value = "File(s) you dragged here:" + f.path;
    document.getElementById("holder").innerHTML = f.path;
    firmware_path = f.path;
  }

  if(firmware_path !== undefined){
    fs.writeFileSync("./script.sh", "./maple_upload " + "cu.SLAB_USBtoUART" + " 2" + " 1EAF:0003 " + "./SFC_1_V1.0.ino.bin", (err) => {
      if(err){
        console.log("An error ocurred creating the file "+ err.message)
      }
      console.log("The file has been succesfully saved");
    });
    return;
  }


});

document.addEventListener('dragover', function (e) {
  e.preventDefault();
  e.stopPropagation();
});

function appendToDroidOutput(msg) { getDroidOutput().value += msg; };
function setStatus(msg)           { getStatus().innerHTML = msg; };

function select_file() {
  dialog.showOpenDialog((fileNames) => {
    // fileNames is an array that contains all the selected
    if(fileNames === undefined){
      console.log("No file selected");
      return;

    }

    else{
      console.log(fileNames);
      firmware_path = fileNames[0];
    }

  });
}

function upload(){

  if(firmware_path === undefined){
    alert("Drag the desired firmware file in the field");
    return;
  }

  document.getElementById("droid-output").value = "";

  //sleep(250);
  //sleep(250);

  document.getElementById('droid-output').value = "";
  start_printing = 0;

  var TextArea = document.getElementById('droid-output');

  const exec = require('child_process').exec;
  var yourscript = exec('sh ./script.sh',
  (error, stdout, stderr) => {
    console.log(`${stdout}`);
    console.log(`${stderr}`);

    document.getElementById("droid-output").value = `${stdout}`+ "\\\n";
    TextArea.scrollTop = TextArea.scrollHeight;

    if (error !== null) {
      console.log(`exec error: ${error}`);
      document.getElementById("droid-output").value = "Download unsuccesfull" + "\\\n";
    }
    else{
      console.log("Download succesfull");
      //document.getElementById("droid-output").value = "Download succesfull!!";
    }
  });

  TextArea.scrollBottom = TextArea.scrollHeight;


}

Is it because you wrote an absolute path for your binary into your code, so when the files (particularly SFC_1_V1.0.ino.bin) are put into the asar archive, your code doesn’t know where to find the process it’s supposed to execute?

Hi, thanks for your answer. That line was just a default adress for testing. The filepath is being overwritten when the user drap and drops the file into the field or click on the button to browse to the file using the dialog.