Skip to content

Commit

Permalink
fix: log levels (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh <[email protected]>
  • Loading branch information
innerdvations and joshuaellis authored May 20, 2024
1 parent 0494300 commit 109e6f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-frogs-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@strapi/pack-up': patch
---

Use correct log level for all errors
38 changes: 19 additions & 19 deletions src/node/tasks/dts/diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ const printDiagnostic = (
diagnostic: ts.Diagnostic,
{ logger, cwd }: { logger: Logger; cwd: string }
) => {
let output = ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine);

if (diagnostic.file && diagnostic.start) {
const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine);

const file = path.relative(cwd, diagnostic.file.fileName);

const output = [
output = [
`${chalk.cyan(file)}:${chalk.cyan(line + 1)}:${chalk.cyan(character + 1)} - `,
`${chalk.gray(`TS${diagnostic.code}:`)} ${message}`,
].join('');
}

switch (diagnostic.category) {
case ts.DiagnosticCategory.Error:
logger.error(output);
break;
case ts.DiagnosticCategory.Warning:
logger.warn(output);
break;
case ts.DiagnosticCategory.Message:
logger.info(output);
break;
case ts.DiagnosticCategory.Suggestion:
logger.info(output);
break;
default:
break;
}
} else {
logger.info(ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine));
switch (diagnostic.category) {
case ts.DiagnosticCategory.Error:
logger.error(output);
break;
case ts.DiagnosticCategory.Warning:
logger.warn(output);
break;
case ts.DiagnosticCategory.Message:
logger.info(output);
break;
case ts.DiagnosticCategory.Suggestion:
logger.info(output);
break;
default:
break;
}
};

Expand Down

0 comments on commit 109e6f0

Please sign in to comment.