Skip to content

Commit

Permalink
feat: Improve relative file path handling in filesAutoImport
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed May 24, 2024
1 parent 9f532d3 commit 5aa78d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion typescript/src/completions/filesAutoImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default () => {
const files = collected.filter(f => f.endsWith(ext))
for (const file of files) {
const fullPath = nodeModules.path.join(root, file)
const relativeToFile = nodeModules.path.relative(nodeModules.path.dirname(sourceFile.fileName), fullPath).replaceAll('\\', '/')
let relativeToFile = nodeModules.path.relative(nodeModules.path.dirname(sourceFile.fileName), fullPath).replaceAll('\\', '/')
if (!relativeToFile.startsWith('.')) relativeToFile = `./${relativeToFile}`
const lastModified = nodeModules.fs.statSync(fullPath).mtime
const lastModifiedFormatted = timeDifference(Date.now(), lastModified.getTime())
const importPath = (item.importPath ?? '$path').replaceAll('$path', relativeToFile)
Expand Down

0 comments on commit 5aa78d0

Please sign in to comment.