Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Add a warning, stop the tool when theres no device (root)
Browse files Browse the repository at this point in the history
  • Loading branch information
reisxd committed Jul 5, 2022
1 parent 9f4db83 commit cb9904d
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,16 @@ async function getYTVersion () {
);
return await exitProcess();
}
ytVersion = await getYTVersion();
excludedPatches += ' --mount';
isRooted = true;

if (foundDevice) {
ytVersion = await getYTVersion();
excludedPatches += ' --mount';
isRooted = true;
} else {
throw new Error(
"Couldn't find the device. Please plug in the device."
);
}
}
if (!argParser.options.exclude.includes(',')) {
excludedPatches = ` -e ${argParser.options.exclude}`;
Expand Down Expand Up @@ -443,8 +450,12 @@ async function getYTVersion () {
const patchesChoice = [];

for (const patchName of patchesArray) {
let patch = patchName.replace(firstWord, '').replace(/\s/g, '');
if (patch === 'microg-support') patch += ' (Root required)';
if (patch === 'hide-cast-button') patch += ' (Root required)';

patchesChoice.push({
name: patchName.replace(firstWord, '').replace(/\s/g, '')
name: patch
});
}

Expand All @@ -456,6 +467,13 @@ async function getYTVersion () {
choices: patchesChoice
}
]);

if (patchesChoice.length === patchesChoosed.patches.length) {
throw new Error(
'You excluded every single patch... I guess you want to use YouTube?'
);
}

for (const patch of patchesChoosed.patches) {
if (patch.includes('microg-support')) {
if (!adbExists) {
Expand All @@ -464,11 +482,17 @@ async function getYTVersion () {
);
return await exitProcess();
}
ytVersion = await getYTVersion();
patches += ' --mount';
isRooted = true;
if (foundDevice) {
ytVersion = await getYTVersion();
patches += ' --mount';
isRooted = true;
} else {
throw new Error(
"Couldn't find the device. Please plug in the device."
);
}
}
patches += ` -e ${patch}`;
patches += ` -e ${patch.replace(' (Root required)', '')}`;
}

if (fs.existsSync('./revanced/youtube.apk') && !isRooted) {
Expand Down

0 comments on commit cb9904d

Please sign in to comment.