This commit is contained in:
Scott Idem
2022-05-07 16:53:52 -04:00
parent 8283a4b0f7
commit d67d0085ef

View File

@@ -467,15 +467,15 @@ exports.kill_processes = async function ({process_name = null}) {
console.log('*** Electron framework export: kill_processes() ***');
console.log(process_name); // process_name or grep pattern
let command = '';
let cmd = '';
if (os.platform == 'darwin') {
// command = `osascript -e 'quit app "${process_name}" saving no'`;
command = `osascript -e 'quit application "${process_name}" saving no'`;
// cmd = `osascript -e 'quit app "${process_name}" saving no'`;
cmd = `osascript -e 'quit application "${process_name}" saving no'`;
} else {
command = `pkill ${process_name}`;
cmd = `pkill ${process_name}`;
}
child_process.exec(command, (err, stdout, stdin) => {
child_process.exec(cmd, (err, stdout, stdin) => {
if (err) throw err;
console.log(stdout);
});
@@ -486,9 +486,9 @@ exports.kill_processes = async function ({process_name = null}) {
if (process_name == 'Parallels:PowerPoint') {
// Regular expression: (Parallels).*(PowerPoint)
// This will find any process with Parallels and PowerPoint in the name
command = `pkill -i -f '(Parallels).*(PowerPoint)'`;
cmd = `pkill -i -f '(Parallels).*(PowerPoint)'`;
child_process.exec(command, (err, stdout, stdin) => {
child_process.exec(cmd, (err, stdout, stdin) => {
if (err) throw err;
console.log(stdout);
});
@@ -506,9 +506,9 @@ exports.kill_processes = async function ({process_name = null}) {
// Run raw osascript
// Updated 2022-05-07
exports.run_osascript = async function ({command=null, interactive=false, language=null, flags='h', program_file=null}) {
exports.run_osascript = async function ({cmd=null, interactive=false, language=null, flags='h', program_file=null}) {
console.log('*** Electron framework export: run_osascript() ***');
console.log(command);
console.log(cmd);
if (os.platform == 'darwin') {
} else {
@@ -518,17 +518,17 @@ exports.run_osascript = async function ({command=null, interactive=false, langua
let osascript_str = '';
if (Array.isArray(command)) {
console.log('List of command strings');
let commands_str = '';
for (let i = 0; i < command.length; i++) {
commands_str += `-e '${command[i]}'`;
if (Array.isArray(cmd)) {
console.log('List of cmd strings');
let cmds_str = '';
for (let i = 0; i < cmd.length; i++) {
cmds_str += `-e '${cmd[i]}'`;
}
osascript_str = `osascript ${commands_str}`
osascript_str = `osascript ${cmds_str}`
} else if (typeof command === 'string') {
console.log('Single command string');
osascript_str = `osascript -e '${command}'`;
} else if (typeof cmd === 'string') {
console.log('Single cmd string');
osascript_str = `osascript -e '${cmd}'`;
} else {
return false;
}
@@ -557,12 +557,12 @@ exports.run_osascript = async function ({command=null, interactive=false, langua
// Run raw command
// Updated 2022-05-07
exports.run_command = async function ({command=null}) {
console.log('*** Electron framework export: run_command() ***');
exports.run_cmd = async function ({cmd=null}) {
console.log('*** Electron framework export: run_cmd() ***');
console.log(`Command String: ${command}`);
console.log(`Command String: ${cmd}`);
child_process.exec(command, (err, stdout, stdin) => {
child_process.exec(cmd, (err, stdout, stdin) => {
if (err) throw err;
console.log(stdout);
console.log(stdin);