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

View File

@@ -2,13 +2,13 @@ const { MonitorType } = require("./monitor-type");
const { chromium } = require("playwright-core");
const { UP, log } = require("../../src/util");
const { Settings } = require("../settings");
const commandExists = require("command-exists-promise");
const childProcess = require("child_process");
const path = require("path");
const Database = require("../database");
const jwt = require("jsonwebtoken");
const config = require("../config");
const { RemoteBrowser } = require("../remote-browser");
const { commandExists } = require("../util-server");
/**
* 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 SMSPlanet = require("./notification-providers/sms-planet");
const SpugPush = require("./notification-providers/spugpush");
const { commandExists } = require("./util-server");
class Notification {
@@ -262,7 +263,6 @@ class Notification {
* @returns {Promise<boolean>} Does the command apprise exist?
*/
static async checkApprise() {
const commandExists = require("command-exists-promise");
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;