Skip to content
Myr

feat(dev): support `NO_COLOR` (#2007)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* feat(dev): support `NO_COLOR` * fmt * remove unused Bun * follow informal standard https://no-color.org/ * fmt * evade denoify bug When removing optional-chaining, denoify creates node:node:process, so I disable the eslint error by a comment. * add test * fix typo * fix test

authored by ryu · committed by GitHub · parent c02b83b · Browse files · 3 files+67 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+67 added−2 removed

  • tests:+45 added−0 removed
  • other:+22 added−2 removed

3 files+67 added−2 removed

modified:deno_dist/helper/dev/index.ts+11 added-1 removed
modified:src/helper/dev/index.test.ts+45 added
124 unmodified lines
125 ])126 })127})128129describe('showRoutes() in NO_COLOR', () => {130 let logs: string[] = []131132 let originalLog: typeof console.log133 beforeAll(() => {134 vi.stubEnv('NO_COLOR', '1')135 originalLog = console.log136 console.log = (...args) => logs.push(...args)137 })138 afterAll(() => {139 vi.unstubAllEnvs()140 console.log = originalLog141 })142143 beforeEach(() => {144 logs = []145 })146 it('should render not colorized output', async () => {147 showRoutes(app)148 expect(logs).toEqual([149 'GET /',150 'GET /named',151 'POST /',152 'PUT /',153 'PATCH /',154 'DELETE /',155 'OPTIONS /',156 'GET /static',157 ])158 })159 it('should render colorized output if colorize: true', async () => {160 showRoutes(app, { colorize: true })161 expect(logs).toEqual([162 '\x1b[32mGET\x1b[0m /',163 '\x1b[32mGET\x1b[0m /named',164 '\x1b[32mPOST\x1b[0m /',165 '\x1b[32mPUT\x1b[0m /',166 '\x1b[32mPATCH\x1b[0m /',167 '\x1b[32mDELETE\x1b[0m /',168 '\x1b[32mOPTIONS\x1b[0m /',169 '\x1b[32mGET\x1b[0m /static',170 ])171 })172})173174describe('geRouterName()', () => {175 it('Should return the correct router name', async () => {176 const app = new Hono({177 router: new RegExpRouter(),
4 unmodified lines
modified:src/helper/dev/index.ts+11 added-1 removed