This commit is contained in:
Eugene Pankov
2020-02-05 15:16:31 +03:00
parent 04d4474648
commit 3f8b933d05
6 changed files with 44 additions and 41 deletions

View File

@@ -1,13 +1,15 @@
let lru = require('lru-cache')({ max: 256, maxAge: 250 })
let fs = require('fs')
let origLstat = fs.realpathSync.bind(fs)
import createLRU from 'lru-cache'
import * as fs from 'fs'
const lru = createLRU({ 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
if (r) {
return r
}
r = origLstat(p)
lru.set(p, r)