1
1
mirror of https://github.com/neosubhamoy/pytubepp-helper.git synced 2026-02-04 11:22:22 +05:30

(refactor): added gnome-terminal as deb, rpm dependency and introduced package manager based linux distro detection

This commit is contained in:
2024-12-30 23:38:56 +05:30
Verified
parent bac65b9832
commit abd6088ca9
5 changed files with 40 additions and 15 deletions

View File

@@ -65,20 +65,27 @@ export async function detectDistro(): Promise<string | null> {
}
}
export function detectDistroBase(distro: string | null): string | null{
if(distro) {
if(['debian', 'ubuntu', 'pop', 'kali'].includes(distro)) {
return 'debian';
} else if (['rhel', 'fedora', 'centos', 'rocky'].includes(distro)) {
return 'rhel';
export async function detectPackageManager(): Promise<string | null> {
try{
const output = await new Command('detect-pkgmngr', ['-c', 'command -v apt || command -v dnf || command -v pacman']).execute();
if (output.code === 0) {
return output.stdout;
} else {
return 'other';
return output.stdout;
}
} else {
} catch (error) {
console.error(error);
return null;
}
}
export function extractPkgMngrName(path: string): string | null {
const pattern = /^\s*(.*\/)?([^\/\s]+)\s*$/;
const match = path.trim().match(pattern);
if (!match) return null;
return match[2];
}
export function extractDistroId(input: string): string | null {
const regex = /ID=([a-zA-Z]+)/;
const match = input.match(regex);