This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add individual log function
- Loading branch information
Lotus
authored and
Lotus
committed
Jul 14, 2021
1 parent
3b7bbea
commit 2737e89
Showing
4 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface PackageJson { | ||
name: string; | ||
version: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import chalk from "chalk"; | ||
import log from "./log"; | ||
|
||
test("Log function", () => { | ||
const results: any = []; | ||
jest | ||
.spyOn(process.stdout, "write") | ||
.mockImplementation(val => results.push(String(val).trim())); | ||
|
||
log("Hello"); | ||
log(chalk.red("Red")); | ||
|
||
expect(results).toEqual(["Hello", chalk.red("Red")]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { format } from "util"; | ||
|
||
const log = (text: string): void => { | ||
process.stdout.write(`${format(text)}\n`); | ||
}; | ||
|
||
export default log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters