mirror of
https://github.com/Eugeny/tabby
synced 2024-11-15 01:17:14 +00:00
17 lines
442 B
TypeScript
17 lines
442 B
TypeScript
import * as LRU from 'lru-cache'
|
|
import * as fs from 'fs'
|
|
const lru = new LRU({ max: 256, maxAge: 250 })
|
|
const origLstat = fs.realpathSync.bind(fs)
|
|
|
|
// NB: The biggest offender of thrashing realpathSync is the node module system
|
|
// itself, which we can't get into via any sane means.
|
|
require('fs').realpathSync = function (p) {
|
|
let r = lru.get(p)
|
|
if (r) {
|
|
return r
|
|
}
|
|
|
|
r = origLstat(p)
|
|
lru.set(p, r)
|
|
return r
|
|
}
|