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