Skip to content

Commit

Permalink
chore: reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Dec 11, 2024
1 parent 8df8ebe commit 412c67a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 189 deletions.
143 changes: 0 additions & 143 deletions packages/vitest/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,6 @@ Repository: https://github.com/acornjs/acorn.git
---------------------------------------

## ansi-styles
License: MIT
By: Sindre Sorhus
Repository: chalk/ansi-styles

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## birpc
License: MIT
By: Anthony Fu
Expand Down Expand Up @@ -477,23 +460,6 @@ Repository: git+https://github.com/WebReflection/flatted.git
---------------------------------------

## get-east-asian-width
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/get-east-asian-width

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## get-tsconfig
License: MIT
By: Hiroki Osame
Expand Down Expand Up @@ -575,23 +541,6 @@ Repository: jonschlinkert/is-extglob
---------------------------------------

## is-fullwidth-code-point
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/is-fullwidth-code-point

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## is-glob
License: MIT
By: Jon Schlinkert, Brian Woodward, Daniel Perez
Expand Down Expand Up @@ -811,23 +760,6 @@ Repository: micromatch/micromatch
---------------------------------------

## mimic-fn
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/mimic-fn

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## mlly
License: MIT
Repository: unjs/mlly
Expand Down Expand Up @@ -856,23 +788,6 @@ Repository: unjs/mlly
---------------------------------------

## onetime
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/onetime

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## p-limit
License: MIT
By: Sindre Sorhus
Expand Down Expand Up @@ -1051,23 +966,6 @@ Repository: privatenumber/resolve-pkg-maps
---------------------------------------

## restore-cursor
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/restore-cursor

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## reusify
License: MIT
By: Matteo Collina
Expand Down Expand Up @@ -1125,30 +1023,6 @@ Repository: git://github.com/feross/run-parallel.git
---------------------------------------

## signal-exit
License: ISC
By: Ben Coe
Repository: https://github.com/tapjs/signal-exit.git

> The ISC License
>
> Copyright (c) 2015, Contributors
>
> Permission to use, copy, modify, and/or distribute this software
> for any purpose with or without fee is hereby granted, provided
> that the above copyright notice and this permission notice
> appear in all copies.
>
> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
> OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
> LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
> OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
> WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
> ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------

## sisteransi
License: MIT
By: Terkel Gjervig
Expand Down Expand Up @@ -1178,23 +1052,6 @@ Repository: https://github.com/terkelg/sisteransi
---------------------------------------

## slice-ansi
License: MIT
Repository: chalk/slice-ansi

> MIT License
>
> Copyright (c) DC <[email protected]>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------

## strip-literal
License: MIT
By: Anthony Fu
Expand Down
22 changes: 12 additions & 10 deletions packages/vitest/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const CLEAR_SCREEN = '\x1Bc'
export class Logger {
private _clearScreenPending: string | undefined
private _highlights = new Map<string, string>()
private exitListeners: Listener[] = []
private cleanupListeners: Listener[] = []
public console: Console

constructor(
Expand All @@ -49,7 +49,7 @@ export class Logger {
) {
this.console = new Console({ stdout: outputStream, stderr: errorStream })
this._highlights.clear()
this.addProcessExitListeners()
this.addCleanupListeners()
this.registerUnhandledRejection()

;(this.outputStream as Writable).write(HIDE_CURSOR)
Expand Down Expand Up @@ -311,14 +311,18 @@ export class Logger {
return 'columns' in this.outputStream ? this.outputStream.columns : 80
}

onExit(listener: Listener) {
this.exitListeners.push(listener)
onTerminalCleanup(listener: Listener) {
this.cleanupListeners.push(listener)
}

private addProcessExitListeners() {
const onExit = (signal?: string | number, exitCode?: number) => {
this.exitListeners.forEach(fn => fn())
private addCleanupListeners() {
const cleanup = () => {
this.cleanupListeners.forEach(fn => fn())
;(this.outputStream as Writable).write(SHOW_CURSOR)
}

const onExit = (signal?: string | number, exitCode?: number) => {
cleanup()

// Interrupted signals don't set exit code automatically.
// Use same exit code as node: https://nodejs.org/api/process.html#signal-events
Expand All @@ -337,9 +341,7 @@ export class Logger {
process.off('SIGINT', onExit)
process.off('SIGTERM', onExit)
process.off('exit', onExit)

this.exitListeners.forEach(fn => fn())
;(this.outputStream as Writable).write(SHOW_CURSOR)
cleanup()
})
}

Expand Down
7 changes: 4 additions & 3 deletions packages/vitest/src/node/reporters/renderers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { SnapshotSummary } from '@vitest/snapshot'
import { stripVTControlCharacters } from 'node:util'
import { slash } from '@vitest/utils'
import { basename, dirname, isAbsolute, relative } from 'pathe'
import sliceAnsi from 'slice-ansi'
import c from 'tinyrainbow'
import {
F_CHECK,
Expand Down Expand Up @@ -238,9 +237,11 @@ export function padSummaryTitle(str: string) {
}

export function truncateString(text: string, maxLength: number): string {
if (stripVTControlCharacters(text).length <= maxLength) {
const plainText = stripVTControlCharacters(text)

if (plainText.length <= maxLength) {
return text
}

return `${sliceAnsi(text, 0, maxLength - 1)}…`
return `${plainText.slice(0, maxLength - 1)}…`
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class WindowRenderer {
)

// Write buffered content on unexpected exits, e.g. direct `process.exit()` calls
this.options.logger.onExit(() => {
this.options.logger.onTerminalCleanup(() => {
this.flushBuffer()
this.stop()
})
Expand Down
33 changes: 1 addition & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 412c67a

Please sign in to comment.