feat: make path in error message relative to rootDir

This commit is contained in:
2025-09-12 02:08:24 +02:00
parent 6c3889d2a0
commit 74a724c287

View File

@@ -125,26 +125,27 @@ export class CustomService extends core.Service {
} }
} }
async checkFile(path: string, lang: string): Promise<boolean> { async checkFile(filePath: string, lang: string): Promise<boolean> {
const url = this.makeFileUrl(path) const url = this.makeFileUrl(filePath)
const content = this.getFileContent(path) const content = this.getFileContent(filePath)
this.project.onDidOpen(url, lang, 0, content) this.project.onDidOpen(url, lang, 0, content)
const docAndNode = this.project.getClientManaged(url) const docAndNode = this.project.getClientManaged(url)
if (!docAndNode) { if (!docAndNode) {
action.error(`File ${path} is not loaded`) action.error(`File ${filePath} is not loaded`)
return false return false
} }
const { node } = docAndNode const { node } = docAndNode
const errors = core.FileNode.getErrors(node) const errors = core.FileNode.getErrors(node)
if (errors.length !== 0) { if (errors.length !== 0) {
const msg = `${errors.length} error${errors.length > 1 ? "s" : ""} in ${path}` const relPath = path.relative(this.rootDir, filePath)
const msg = `${errors.length} error${errors.length > 1 ? "s" : ""} in ${relPath}`
if (this.options.verbose) { if (this.options.verbose) {
action.startGroup(msg) action.startGroup(msg)
for (const err of errors) { for (const err of errors) {
action.error( action.error(
err.message, err.message,
this.getErrorProperties(err, path, content) this.getErrorProperties(err, filePath, content)
) )
} }
action.endGroup() action.endGroup()