Skip to content

Commit f45b55c

Browse files
committed
fix: resolve path in updateLinkManifest
1 parent cddef86 commit f45b55c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/core/cache.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { dirname } from 'path'
33
import { fs } from './fs'
44

55
export interface JSONCache<T = any> {
6+
path: string
67
dirty: boolean
78
get(key: string): T
89
set(key: string, value: T | null): void
@@ -36,6 +37,9 @@ export function loadCache<T>(
3637
}
3738
let dirty = false
3839
cache = caches[cachePath] = {
40+
get path() {
41+
return cachePath
42+
},
3943
get dirty() {
4044
return dirty
4145
},

src/core/loadLinkManifest.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'path'
1+
import { join, resolve } from 'path'
22
import toml from 'markty-toml'
33
import { ConfigIniParser } from 'config-ini-parser'
44
import { JSONCache, loadCache } from './cache'
@@ -25,15 +25,17 @@ export function loadLinkManifest(root: string, skipUpdate?: boolean) {
2525
}
2626

2727
export function updateLinkManifest(links: JSONCache<LinkMetaData>) {
28-
links.find((link, linkPath) => {
28+
const root = resolve(links.path, '../../..')
29+
links.find((prevData, linkId) => {
30+
const linkPath = join(root, linkId)
2931
if (fs.isLink(linkPath)) {
30-
const newLink = loadLinkMetaData(linkPath, link)!
31-
if (newLink) {
32-
newLink == link || links.set(linkPath, newLink)
32+
const newData = loadLinkMetaData(linkPath, prevData)!
33+
if (newData) {
34+
newData == prevData || links.set(linkId, newData)
3335
return false
3436
}
3537
}
36-
links.set(linkPath, null)
38+
links.set(linkId, null)
3739
return false
3840
})
3941
}

0 commit comments

Comments
 (0)