Skip to content

Commit

Permalink
fix: linter log undefined name
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Jul 19, 2024
1 parent 8fc3ebe commit b250c7d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions apps/cli/src/command/lint.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import pluralize from 'pluralize';
import { ZodError } from 'zod';

import { check } from '../linter';
import { SignaleRenderer } from '../utils/listr';
import { LoadLocalConfigurationTask } from './diff.command';
import { BaseCommand } from './helper';

Expand All @@ -28,7 +29,13 @@ export const LintTask = (): ListrTask<{ local: ADCSDK.Configuration }> => ({

// normal case
const resourceType = pluralize.singular(error.path[0] as string);
const resourceName = ctx.local[error.path[0]][error.path[1]].name;
const resource = ctx.local[error.path[0]][error.path[1]];
const resourceName =
resourceType === 'ssl'
? resource.snis
: resourceType === 'consumer'
? resource.username
: resource.name;
err += `#${idx + 1} ${
error.message
} at ${resourceType}: "${resourceName}", field: "${(
Expand Down Expand Up @@ -59,10 +66,13 @@ export const LintCommand = new BaseCommand('lint')
.action(async () => {
const opts = LintCommand.optsWithGlobals();

const tasks = new Listr([
LoadLocalConfigurationTask(opts.file, {}),
LintTask(),
]);
const tasks = new Listr(
[LoadLocalConfigurationTask(opts.file, {}), LintTask()],
{
renderer: SignaleRenderer,
rendererOptions: { verbose: opts.verbose },
},
);

try {
await tasks.run();
Expand Down

0 comments on commit b250c7d

Please sign in to comment.