Skip to content

Commit

Permalink
Merge pull request #752 from particle-iot/bug/sc-129396/particle-logi…
Browse files Browse the repository at this point in the history
…n-sso-is-partially-borken-on

bug/sc-129396/particle-login-sso-is-partially-borken-on
  • Loading branch information
hugomontero authored Jul 18, 2024
2 parents 197c6b6 + 49376ba commit 5d7a149
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/openurl.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// Copy of https://github.com/rauschma/openurl with additional error handling
const spawn = require('child_process').spawn;
const path = require('path');

let command;

switch (process.platform) {
case 'darwin':
case 'darwin':{
command = 'open';
break;
case 'win32':
command = 'explorer.exe';
}
case 'win32':{
const binPath = `${process.env.SYSTEMROOT || process.env.windir || 'C:\\Windows'}`;
command = path.join(binPath, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell');
break;
case 'linux':
}
case 'linux': {
command = 'xdg-open';
break;
}
default:
throw new Error('Unsupported platform: ' + process.platform);
}
Expand All @@ -25,7 +30,8 @@ switch (process.platform) {
*/

function open(url, callback) {
const child = spawn(command, [url]);
const args = process.platform === 'win32' ? ['Start', url] : [url];
const child = spawn(command, args);
child.on('error', (error) => {
callback(error);
});
Expand Down

0 comments on commit 5d7a149

Please sign in to comment.