From 048e663114fd60ac9250c330b64c493808b4df62 Mon Sep 17 00:00:00 2001 From: theofficialomega <30985701+BellezaEmporium@users.noreply.github.com> Date: Sat, 2 Aug 2025 12:38:31 +0200 Subject: [PATCH] ditch old packages for native JS alternatives --- package-lock.json | 4 +--- package.json | 4 +--- scripts/commands/playlist/test.ts | 8 +++++--- scripts/utils.ts | 11 +++++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9bc08232ed..f50dd37b68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "axios": "^1.11.0", "chalk": "^5.4.1", "cli-progress": "^3.12.0", - "command-exists": "^1.2.9", "commander": "^14.0.0", "console-table-printer": "^2.14.6", "cross-env": "^10.0.0", @@ -42,8 +41,7 @@ "lodash.uniqueid": "^4.0.1", "m3u-linter": "^0.4.2", "node-cleanup": "^2.1.2", - "tsx": "^4.20.3", - "valid-url": "^1.0.9" + "tsx": "^4.20.3" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index e7dbb04c7c..334c1875a5 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "axios": "^1.11.0", "chalk": "^5.4.1", "cli-progress": "^3.12.0", - "command-exists": "^1.2.9", "commander": "^14.0.0", "console-table-printer": "^2.14.6", "cross-env": "^10.0.0", @@ -72,7 +71,6 @@ "lodash.uniqueid": "^4.0.1", "m3u-linter": "^0.4.2", "node-cleanup": "^2.1.2", - "tsx": "^4.20.3", - "valid-url": "^1.0.9" + "tsx": "^4.20.3" } } diff --git a/scripts/commands/playlist/test.ts b/scripts/commands/playlist/test.ts index 52c3d9cf1c..af398acf96 100644 --- a/scripts/commands/playlist/test.ts +++ b/scripts/commands/playlist/test.ts @@ -4,8 +4,8 @@ import { PlaylistParser, StreamTester, CliTable, DataProcessor, DataLoader } fro import { Stream } from '../../models' import { program } from 'commander' import { eachLimit } from 'async-es' -import commandExists from 'command-exists' import chalk from 'chalk' +import child_process from 'node:child_process' import os from 'node:os' import dns from 'node:dns' import type { DataLoaderData } from '../../types/dataLoader' @@ -46,10 +46,12 @@ async function main() { return } - if (!commandExists.sync('ffprobe')) { + try { + child_process.execSync('ffprobe -version', { stdio: 'ignore' }) + } catch { logger.error( chalk.red( - 'For the script to work, the “ffprobe” library must be installed (https://ffmpeg.org/download.html)' + 'For the script to work, the "ffprobe" library must be installed (https://ffmpeg.org/download.html)' ) ) diff --git a/scripts/utils.ts b/scripts/utils.ts index c7d4815632..7ff419de21 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,5 +1,8 @@ -import validUrl from 'valid-url' - -export function isURI(string: string) { - return validUrl.isUri(encodeURI(string)) +export function isURI(string: string): boolean { + try { + new URL(string) + return true + } catch { + return false + } }