mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-29 09:55:43 +08:00
fix: make typescriptformatter support 0.5 of fork checker (#5879)
This commit is contained in:
committed by
Joe Haddad
parent
1164f6bc30
commit
3a14e8fc26
25
packages/react-dev-utils/typescriptFormatter.js
vendored
25
packages/react-dev-utils/typescriptFormatter.js
vendored
@@ -13,13 +13,24 @@ const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
|
||||
function formatter(message, useColors) {
|
||||
const hasGetters = typeof message.getFile === 'function';
|
||||
const colors = new chalk.constructor({ enabled: useColors });
|
||||
const messageColor = message.isWarningSeverity() ? colors.yellow : colors.red;
|
||||
|
||||
const source =
|
||||
message.getFile() &&
|
||||
fs.existsSync(message.getFile()) &&
|
||||
fs.readFileSync(message.getFile(), 'utf-8');
|
||||
let source;
|
||||
|
||||
if (hasGetters) {
|
||||
source =
|
||||
message.getFile() &&
|
||||
fs.existsSync(message.getFile()) &&
|
||||
fs.readFileSync(message.getFile(), 'utf-8');
|
||||
} else {
|
||||
source =
|
||||
message.file &&
|
||||
fs.existsSync(message.file) &&
|
||||
fs.readFileSync(message.file, 'utf-8');
|
||||
}
|
||||
|
||||
let frame = '';
|
||||
|
||||
if (source) {
|
||||
@@ -33,9 +44,11 @@ function formatter(message, useColors) {
|
||||
.join(os.EOL);
|
||||
}
|
||||
|
||||
const severity = hasGetters ? message.getSeverity() : message.severity;
|
||||
|
||||
return [
|
||||
messageColor.bold(`Type ${message.getSeverity().toLowerCase()}: `) +
|
||||
message.getContent() +
|
||||
messageColor.bold(`Type ${severity.toLowerCase()}: `) +
|
||||
(hasGetters ? message.getContent() : message.content) +
|
||||
' ' +
|
||||
messageColor.underline(`TS${message.code}`),
|
||||
'',
|
||||
|
||||
Reference in New Issue
Block a user