Skip to content

Commit

Permalink
chore: imporved Warn
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed Jun 12, 2024
1 parent 7e30430 commit 686f993
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 292 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-stingrays-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperse/ts-node-paths": patch
---

imporved `Warn`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"eslint": "^9.4.0",
"execa": "^9.2.0",
"husky": "9.0.11",
"lint-staged": "15.2.5",
"lint-staged": "15.2.6",
"npm-run-all": "^4.1.5",
"tsup": "^8.1.0",
"tsx": "^4.15.2",
Expand Down
5 changes: 3 additions & 2 deletions src/tool/showWarns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const warns = new Map<string, boolean>();
/**
* A help to show warns only once.
* @param message - The message to show.
* @param context - The context of the message.
* @returns
*/
export const showWarns = (message: string) => {
export const showWarns = (message: string, context?: string) => {
if (warns.get(message)) return;
console.log(`${yellow('WARN')}: ${message}`);
console.log(`${yellow('WARN')}: ${message}`, context);
warns.set(message, true);
};
2 changes: 1 addition & 1 deletion src/tsconfig/getCompilerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getCompilerOptions(path: string): CompilerOptions {
}

if (compilerOptions.baseUrl === './src') {
showWarns("`baseUrl` use './' instead of `./src`");
showWarns("`baseUrl` use './' instead of `./src`", path);
}

return {
Expand Down
Loading

0 comments on commit 686f993

Please sign in to comment.