0

Is it possible to call a native process in Electron?

For example, if I want to call git or something like that is it possible?

Example:

var process = new Process();
process.executable = File.ApplicationDirectory() + "/utilities/my_process_not_node_js";
process.arguments = "-html=5 -include-css=true -mobile-support=true";
process.addEventListener("standardInput", handleInput);
process.run();
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231

1 Answers1

1

Sure you can you have access to the complete NodeJS builtin API.

For example if you want to execute a simple ls -lh /usr command, you can do:

const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr']);

ls.stdout.on('data', data => console.log(`stdout: ${data}`));

ls.stderr.on('data', data => console.log(`stderr: ${data}`));

ls.on('close', code => console.log(`child process exited with code ${code}`));
Damien
  • 3,915
  • 1
  • 17
  • 18