mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
cordis 4.0.0-rc.6, plugin-loader, -include, -group, -timer, -hmr, -logger-console, cosmokit 1.8.1, schemastery 3.18.0 — copied from the cordis-workspace checkout, flattened under vendor/, original npm names, private: true. vendor/README.md is the manifest: upstream repos + commit SHAs, local-modification log, sync procedure. Local modification: hmr's locale YAML imports and .i18n() call removed (avoids a runtime YAML import hook we don't vendor).
37 lines
1018 B
TypeScript
37 lines
1018 B
TypeScript
import { Context } from 'cordis'
|
|
import { BuildFailure } from 'esbuild'
|
|
import { codeFrameColumns } from '@babel/code-frame'
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
function isBuildFailure(e: any): e is BuildFailure {
|
|
return Array.isArray(e?.errors) && e.errors.every((error: any) => error.text)
|
|
}
|
|
|
|
/** Log HMR build failures with code frames when source locations are available. */
|
|
export function handleError(ctx: Context, e: any) {
|
|
if (!isBuildFailure(e)) {
|
|
ctx.logger.warn(e)
|
|
return
|
|
}
|
|
|
|
for (const error of e.errors) {
|
|
if (!error.location) {
|
|
ctx.logger.warn(error.text)
|
|
continue
|
|
}
|
|
try {
|
|
const { file, line, column } = error.location
|
|
const source = readFileSync(file, 'utf8')
|
|
const formatted = codeFrameColumns(source, {
|
|
start: { line, column },
|
|
}, {
|
|
highlightCode: true,
|
|
message: error.text,
|
|
})
|
|
ctx.logger.warn(`File: ${file}:${line}:${column}\n` + formatted)
|
|
} catch (e) {
|
|
ctx.logger.warn(e)
|
|
}
|
|
}
|
|
}
|