Skip to content

Commit

Permalink
fixed plugin execution on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby Johnson committed Feb 2, 2019
1 parent b4c2447 commit cc90625
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
36 changes: 26 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ const { spawn } = require('cross-spawn');
const path = require('path');
const os = require('os');
let manifest = require(path.join(config.executable.path, config.executable.manifest));
const pluginExe = os.platform == 'win32' ? config.executable.winexe : config.executable.osxexe;
const pluginExe = os.platform == 'win32' ? config.executable.winexe : `./${config.executable.osxexe}`;

const forked = fork('server.js');
console.log(Chalk.green('<status>Web Socket Server Started....'));

console.log('Green Text denotes hardware action\nGreen Highlight denotes hardware messages sent\nCyan highlight denotes messages received from plugin\n');


console.log([
'Green Text denotes hardware action',
'Green Highlight denotes hardware messages sent',
'Cyan highlight denotes messages received from plugin'
].join('\n'));

// Registration Stuff
let info = {
Expand All @@ -32,14 +38,24 @@ let info = {
]
};

let registrationParams = ['-port', config.server.port, '-pluginUUID', manifest.Actions[0].UUID,'-registerEvent','registerEvent','-info', JSON.stringify(info)];
spawn(pluginExe, registrationParams, { cwd: config.executable.path }, (err, data) => {
if(err){
console.log(Chalk.red(`ERROR: ${err}`));
} else {
console.log(Chalk.green(`DATA: ${data}`));
}
} );
let registrationParams = [
'-port', config.server.port,
'-pluginUUID', manifest.Actions[0].UUID,
'-registerEvent','registerEvent',
'-info', JSON.stringify(info)
];

console.log(`spawning ${pluginExe} in ${config.executable.path}`);
const plugin = spawn(pluginExe, registrationParams, { cwd: config.executable.path, stdio: 'inherit' });
console.log(`${pluginExe} has a PID of ${plugin.pid}`);

plugin.on('error', () => {
console.log(arguments);
});

plugin.on('exit', () => {
console.log(arguments);
});

promptUser();

Expand Down
27 changes: 23 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc90625

Please sign in to comment.