Skip to content

Commit

Permalink
Merge pull request #16 from Haberkamp/improve-error-messages
Browse files Browse the repository at this point in the history
improve error messages
  • Loading branch information
Haberkamp authored Nov 18, 2023
2 parents f3befc9 + 2318815 commit f8d8d60
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const cruiseResult: IReporterOutput = await cruise(
{ tsConfig },
);

if (typeof cruiseResult.output === 'string') throw new Error('lul');
if (typeof cruiseResult.output === 'string')
throw new Error('Failed to analyze project; Output is a string.');

const migrationCompleted = cruiseResult.output.modules.every((module) =>
module.source.includes('.ts'),
Expand All @@ -71,7 +72,9 @@ if (migrationCompleted) {

function countDependents(module: IModule): string[] {
return module.dependents.reduce<string[]>((accumulator, dependent) => {
if (typeof cruiseResult.output === 'string') throw new Error('lul');
if (typeof cruiseResult.output === 'string')
throw new Error('Failed to analyze project; Output is a string.');

const dependentsOfDependent = cruiseResult.output.modules.filter(
(currentModule) => currentModule.source === dependent,
);
Expand All @@ -96,7 +99,8 @@ const result = cruiseResult.output.modules.reduce<Array<FileResult>>(
const isTypeScriptFile = moduleReport.source.endsWith('.ts');
if (isTypeScriptFile) return accumulator;

if (typeof cruiseResult.output === 'string') throw new Error('lul');
if (typeof cruiseResult.output === 'string')
throw new Error('Failed to analyze project; Output is a string.');

const dependencyCount = dependencyCounter.countDependencies(
moduleReport,
Expand Down

0 comments on commit f8d8d60

Please sign in to comment.