Rollback "command-exists-promise" as it is not working

This commit is contained in:
Louis Lam 2025-06-15 19:01:55 +08:00
parent 86de907acd
commit 1f4622f5f3
5 changed files with 20 additions and 13 deletions

11
package-lock.json generated
View file

@ -21,7 +21,7 @@
"check-password-strength": "^2.0.5", "check-password-strength": "^2.0.5",
"cheerio": "~1.0.0-rc.12", "cheerio": "~1.0.0-rc.12",
"chroma-js": "~2.4.2", "chroma-js": "~2.4.2",
"command-exists-promise": "~2.0.2", "command-exists": "~1.2.9",
"compare-versions": "~3.6.0", "compare-versions": "~3.6.0",
"compression": "~1.7.4", "compression": "~1.7.4",
"country-flag-emoji-polyfill": "^0.1.8", "country-flag-emoji-polyfill": "^0.1.8",
@ -6892,15 +6892,6 @@
"integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/command-exists-promise": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/command-exists-promise/-/command-exists-promise-2.0.2.tgz",
"integrity": "sha512-T6PB6vdFrwnHXg/I0kivM3DqaCGZLjjYSOe0a5WgFKcz1sOnmOeIjnhQPXVXX3QjVbLyTJ85lJkX6lUpukTzaA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/commander": { "node_modules/commander": {
"version": "10.0.1", "version": "10.0.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",

View file

@ -79,7 +79,7 @@
"check-password-strength": "^2.0.5", "check-password-strength": "^2.0.5",
"cheerio": "~1.0.0-rc.12", "cheerio": "~1.0.0-rc.12",
"chroma-js": "~2.4.2", "chroma-js": "~2.4.2",
"command-exists-promise": "~2.0.2", "command-exists": "~1.2.9",
"compare-versions": "~3.6.0", "compare-versions": "~3.6.0",
"compression": "~1.7.4", "compression": "~1.7.4",
"country-flag-emoji-polyfill": "^0.1.8", "country-flag-emoji-polyfill": "^0.1.8",

View file

@ -2,13 +2,13 @@ const { MonitorType } = require("./monitor-type");
const { chromium } = require("playwright-core"); const { chromium } = require("playwright-core");
const { UP, log } = require("../../src/util"); const { UP, log } = require("../../src/util");
const { Settings } = require("../settings"); const { Settings } = require("../settings");
const commandExists = require("command-exists-promise");
const childProcess = require("child_process"); const childProcess = require("child_process");
const path = require("path"); const path = require("path");
const Database = require("../database"); const Database = require("../database");
const jwt = require("jsonwebtoken"); const jwt = require("jsonwebtoken");
const config = require("../config"); const config = require("../config");
const { RemoteBrowser } = require("../remote-browser"); const { RemoteBrowser } = require("../remote-browser");
const { commandExists } = require("../util-server");
/** /**
* Cached instance of a browser * Cached instance of a browser

View file

@ -77,6 +77,7 @@ const SendGrid = require("./notification-providers/send-grid");
const YZJ = require("./notification-providers/yzj"); const YZJ = require("./notification-providers/yzj");
const SMSPlanet = require("./notification-providers/sms-planet"); const SMSPlanet = require("./notification-providers/sms-planet");
const SpugPush = require("./notification-providers/spugpush"); const SpugPush = require("./notification-providers/spugpush");
const { commandExists } = require("./util-server");
class Notification { class Notification {
@ -262,7 +263,6 @@ class Notification {
* @returns {Promise<boolean>} Does the command apprise exist? * @returns {Promise<boolean>} Does the command apprise exist?
*/ */
static async checkApprise() { static async checkApprise() {
const commandExists = require("command-exists-promise");
return await commandExists("apprise"); return await commandExists("apprise");
} }

View file

@ -1096,3 +1096,19 @@ module.exports.axiosAbortSignal = (timeoutMs) => {
} }
} }
}; };
/**
* By default, command-exists will throw a null error if the command does not exist, which is ugly. The function makes it better.
* Read more: https://github.com/mathisonian/command-exists/issues/22
* @param {string} command Command to check
* @returns {Promise<boolean>} True if command exists, false otherwise
*/
async function commandExists(command) {
try {
await require("command-exists")(command);
return true;
} catch (e) {
return false;
}
}
module.exports.commandExists = commandExists;