Skip to content

Commit

Permalink
kpsewhich will return absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Oct 14, 2024
1 parent ce053da commit 152c449
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,16 @@ function kpsewhich(target: string, isBib: boolean = false): string | undefined {

try {
const args = isBib ? ['-format=.bib', target] : [target]
const kpsewhichReturn = lw.external.sync(command, args, {cwd: lw.root.dir.path || vscode.workspace.workspaceFolders?.[0].uri.path})
const cwd = lw.root.dir.path || vscode.workspace.workspaceFolders?.[0].uri.path
const kpsewhichReturn = lw.external.sync(command, args, { cwd })
if (kpsewhichReturn.status === 0) {
const output = kpsewhichReturn.stdout.toString().replace(/\r?\n/, '')
let output = kpsewhichReturn.stdout.toString().replace(/\r?\n/, '')
logger.log(`kpsewhich returned with '${output}'.`)
if (output !== '') {
if (!path.isAbsolute(output) && cwd) {
output = path.resolve(cwd, output)
logger.log(`kpsewhich resolved to '${output}'.`)
}
kpsecache[query] = output
}
return output
Expand Down

0 comments on commit 152c449

Please sign in to comment.