From eb662c34ecfdecda178d72648e22e03f634ee147 Mon Sep 17 00:00:00 2001 From: Hugo Montero Date: Wed, 8 May 2024 13:10:33 -0600 Subject: [PATCH] fix lint for openurl --- src/lib/openurl.js | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/lib/openurl.js b/src/lib/openurl.js index d1a22eda5..9ed6a2c39 100644 --- a/src/lib/openurl.js +++ b/src/lib/openurl.js @@ -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); } /** @@ -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 };