提交 7bca6492 编写于 作者: fxy060608's avatar fxy060608

chore: format filename

上级 1785a527
......@@ -2,6 +2,8 @@ import path from 'path'
import { normalizePath } from '../utils'
import { uniConsolePlugin } from '../vite/plugins/console'
export { formatAtFilename } from './log'
export * from './env'
export {
initModuleAlias,
......
......@@ -10,6 +10,22 @@ const SIGNAL_H5_NETWORK = ' > Network:'
const networkLogs: string[] = []
export function formatAtFilename(
filename: string,
line?: number,
column?: number
) {
return `at ${colors.cyan(
normalizePath(
path.relative(process.env.UNI_INPUT_DIR, filename.split('?')[0])
) +
':' +
(line || 1) +
':' +
(column || 0)
)}`
}
export const h5ServeFormatter: Formatter = {
test(msg) {
return msg.includes(SIGNAL_H5_LOCAL) || msg.includes(SIGNAL_H5_NETWORK)
......@@ -83,17 +99,7 @@ function buildErrorMessage(
args.push(colors.red(err.message))
}
if (err.id) {
args.push(
`at ${colors.cyan(
normalizePath(
path.relative(process.env.UNI_INPUT_DIR, err.id.split('?')[0])
) +
':' +
(err.loc?.line || 1) +
':' +
(err.loc?.column || 0)
)}`
)
args.push(formatAtFilename(err.id, err.loc?.line, err.loc?.column))
}
if (err.frame) {
args.push(colors.yellow(pad(err.frame)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册