I'm working on a file management system built with node.js and electron.
The file management displays a list of files in a folder and allows the user to run custom commands to batch process the files, such as renaming, custom grouping ect...
However I want to implement a feature that if the user clicks on a file it will open with the text editor of their choice.
I can't get the sublime text editor (or any for that matter) to open with node.js code.
I have looked into other questions here on SO such as "Launch an external application from node.js" and "Is it possible to execute an external program from within node.js?" but none of the answers successfully work for me.
Most of the answers open the file with the "default" program of the operating system which is not what I want. I want to be able to choose the program that opens the file.
I found this code below that calls on global path variables to open external software from node:
const exec = require("child_process").exec
exec('yourApp').unref()
But of course it doesn't work if you replace 'yourApp' with a file path pointing to sublime_text.exe like so:
var exec = require('child_process').exec;
exec('C:/Program Files/Sublime Text 3/sublime_text.exe').unref()
Any help would be very very much appreciated. Thank you