Skip to content

Commit

Permalink
fix lint for openurl
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomontero committed May 8, 2024
1 parent b44db5e commit eb662c3
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/lib/openurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ const spawn = require('child_process').spawn;

let command;

switch(process.platform) {
case 'darwin':
command = 'open';
break;
case 'win32':
command = 'explorer.exe';
break;
case 'linux':
command = 'xdg-open';
break;
default:
throw new Error('Unsupported platform: ' + process.platform);
switch (process.platform) {
case 'darwin':
command = 'open';
break;
case 'win32':
command = 'explorer.exe';
break;
case 'linux':
command = 'xdg-open';
break;
default:
throw new Error('Unsupported platform: ' + process.platform);
}

/**
Expand All @@ -25,29 +25,29 @@ switch(process.platform) {
*/

function open(url, callback) {
const child = spawn(command, [url]);
child.on('error', function (error) {
callback(error);
});
let errorText = "";
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
errorText += data;
});
child.stderr.on('end', function () {
if (errorText.length > 0) {
const error = new Error(errorText);
if (callback) {
callback(error);
} else {
throw error;
}
} else if (callback) {
callback();
}
});
const child = spawn(command, [url]);
child.on('error', (error) => {
callback(error);
});
let errorText = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data)=> {
errorText += data;
});
child.stderr.on('end', () => {
if (errorText.length > 0) {
const error = new Error(errorText);
if (callback) {
callback(error);
} else {
throw error;
}
} else if (callback) {
callback();
}
});
}

module.exports = {
open
open
};

0 comments on commit eb662c3

Please sign in to comment.