Skip to content

Commit

Permalink
Clear terminal when running lint command 🆑
Browse files Browse the repository at this point in the history
  • Loading branch information
01taylop committed Oct 27, 2024
1 parent 1435fe1 commit b73c402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/commands/lint/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { LintOptions } from '@Types/commands'
import { clearTerminal } from '@Utils/terminal'

const lint = (options: LintOptions) => {
clearTerminal()

console.log('Run Lint', options)
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/terminal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { clearTerminal } from '../terminal'
describe('clearTerminal', () => {

it('calls process.stdout.write to clear the terminal', () => {
const mockWrite = jest.spyOn(process.stdout, 'write').mockImplementation(() => true)
const stdoutSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => true)

clearTerminal()

expect(mockWrite).toHaveBeenCalledWith('\x1Bc\x1B[3J\x1B[2J\x1B[H')
expect(stdoutSpy).toHaveBeenCalledWith('\x1Bc\x1B[3J\x1B[2J\x1B[H')
})

})

0 comments on commit b73c402

Please sign in to comment.