Button onclick event with electron.js

Viewed 124

So, I have an electron app, and I want to execute shell command on button click. I can't really find any helpful tips. Thanks.

1 Answers

@cloudzik try this method:

const { exec } = require("child_process");

exec("ls -la", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
});
Related