generated from atls-lab/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from atls/sync/yarn-plugin-test
sync(yarn-plugin-test): dependencies, abstract command
- Loading branch information
Showing
9 changed files
with
809 additions
and
760 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
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,49 @@ | ||
import { BaseCommand } from '@yarnpkg/cli' | ||
import { Option } from 'clipanion' | ||
import React from 'react' | ||
|
||
import { LogRecord } from '@atls/cli-ui-log-record-component' | ||
import { renderStatic } from '@atls/cli-ui-renderer' | ||
|
||
export abstract class AbstractTestCommand extends BaseCommand { | ||
bail = Option.Boolean('-b,--bail', false) | ||
|
||
updateSnapshot = Option.Boolean('-u,--update-shapshot', false) | ||
|
||
findRelatedTests = Option.Boolean('--find-related-tests', false) | ||
|
||
watchMode = Option.Boolean('--watch') | ||
|
||
watchAllMode = Option.Boolean('--watchAll') | ||
|
||
files: Array<string> = Option.Rest({ required: 0 }) | ||
|
||
wrapOutput(): void { | ||
const original = process.stdout.write | ||
|
||
process.stdout.write = (value: Uint8Array | string, ...rest: Array<any>): boolean => { | ||
const items: Array<string> = value.toString().split('\n') | ||
|
||
const logRecords: Array<string> = items.map((item) => { | ||
try { | ||
const logRecord = JSON.parse(item) | ||
|
||
if ('severityText' in logRecord) { | ||
return `${renderStatic(<LogRecord {...logRecord} />)}\n` | ||
} | ||
|
||
return item | ||
} catch { | ||
return item | ||
} | ||
}) | ||
|
||
logRecords.forEach((logRecord) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
original.bind(process.stdout)(logRecord, ...rest) | ||
}) | ||
|
||
return true | ||
} | ||
} | ||
} |
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
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
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