From e9e928c425158c97d0ec3ed89fc10f0e882d49f0 Mon Sep 17 00:00:00 2001 From: PedroManuelAtienzaHuerta Date: Sun, 2 Feb 2025 13:59:57 +0100 Subject: [PATCH 1/2] Update restart-webdav.js Hi, my name is Pedro Manuel, I have modified the file with the aim of clearer error handling and output messages. --- scripts/restart-webdav.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/restart-webdav.js b/scripts/restart-webdav.js index a12b08e8..09af5ec8 100644 --- a/scripts/restart-webdav.js +++ b/scripts/restart-webdav.js @@ -1,16 +1,20 @@ const { exec } = require('child_process'); async function runCommand() { - await new Promise((resolve, reject) => { - exec('node ./bin/run.js webdav restart', (error, stdout, stderr) => { - if (error) { - reject(error); - } - resolve(stdout || stderr); + try { + const output = await new Promise((resolve, reject) => { + exec('node ./bin/run.js webdav restart', (error, stdout, stderr) => { + if (error) { + reject(error); + return; + } + resolve(stdout || stderr); + }); }); - }); + console.log('Command output:', output); + } catch (error) { + console.error('Command failed with error:', error); + } } -runCommand().finally(() => { - process.exit(0); -}); +runCommand(); From 5c5cb27bdb04189cba1f44b598d68fdce3719acc Mon Sep 17 00:00:00 2001 From: larry-internxt Date: Thu, 3 Jul 2025 11:29:57 +0200 Subject: [PATCH 2/2] refactor: remove console.logs and ensure process exits cleanly --- scripts/restart-webdav.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/scripts/restart-webdav.js b/scripts/restart-webdav.js index 09af5ec8..dee66aa7 100644 --- a/scripts/restart-webdav.js +++ b/scripts/restart-webdav.js @@ -1,20 +1,17 @@ const { exec } = require('child_process'); async function runCommand() { - try { - const output = await new Promise((resolve, reject) => { - exec('node ./bin/run.js webdav restart', (error, stdout, stderr) => { - if (error) { - reject(error); - return; - } - resolve(stdout || stderr); - }); + await new Promise((resolve, reject) => { + exec('node ./bin/run.js webdav restart', (error, stdout, stderr) => { + if (error) { + reject(error); + } else { + resolve(stdout ?? stderr); + } }); - console.log('Command output:', output); - } catch (error) { - console.error('Command failed with error:', error); - } + }); } -runCommand(); +runCommand().finally(() => { + process.exit(0); +});