Skip to content

Commit

Permalink
main: try catch scan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
VandeurenGlenn committed Aug 11, 2024
1 parent 4135793 commit 88dab32
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,43 +196,47 @@ async function runModuleReplacements(): Promise<void> {

scanSpinner.message('Scanning files');

const files = await traverseFiles(options.filesDir);
try {
const files = await traverseFiles(options.filesDir);

const scanFilesResult = await scanFiles(
files,
manifestReplacements,
scanSpinner
);
const scanFilesResult = await scanFiles(
files,
manifestReplacements,
scanSpinner
);

if (scanFilesResult.length > 0) {
dependenciesFound = true;
}
if (scanFilesResult.length > 0) {
dependenciesFound = true;
}

if (dependenciesFound) {
scanSpinner.stop('Replaceable modules found.', 2);
} else {
scanSpinner.stop('No replaceable modules found.');
}
if (dependenciesFound) {
scanSpinner.stop('Replaceable modules found.', 2);
} else {
scanSpinner.stop('No replaceable modules found.');
}

if (
options.autoUninstall &&
(dependenciesToRemove.length > 0 || devDependenciesToRemove.length > 0)
) {
const npmSpinner = cl.spinner();
if (
options.autoUninstall &&
(dependenciesToRemove.length > 0 || devDependenciesToRemove.length > 0)
) {
const npmSpinner = cl.spinner();

npmSpinner.start('Removing npm dependencies');
npmSpinner.start('Removing npm dependencies');

if (dependenciesToRemove.length > 0) {
await x('npm', ['rm', '-S', ...dependenciesToRemove]);
}
if (devDependenciesToRemove.length > 0) {
await x('npm', ['rm', '-D', ...devDependenciesToRemove]);
}
if (dependenciesToRemove.length > 0) {
await x('npm', ['rm', '-S', ...dependenciesToRemove]);
}
if (devDependenciesToRemove.length > 0) {
await x('npm', ['rm', '-D', ...devDependenciesToRemove]);
}

npmSpinner.stop('npm dependencies removed');
}
npmSpinner.stop('npm dependencies removed');
}

if (options.fix) {
await fixFiles(scanFilesResult);
if (options.fix) {
await fixFiles(scanFilesResult);
}
} catch (error) {
scanSpinner.stop(error as string, 1);
}
}

0 comments on commit 88dab32

Please sign in to comment.