1 module.exports = realpath
2 realpath.realpath = realpath
3 realpath.sync = realpathSync
4 realpath.realpathSync = realpathSync
5 realpath.monkeypatch = monkeypatch
6 realpath.unmonkeypatch = unmonkeypatch
9 var origRealpath = fs.realpath
10 var origRealpathSync = fs.realpathSync
12 var version = process.version
13 var ok = /^v[0-5]\./.test(version)
14 var old = require('./old.js')
16 function newError (er) {
17 return er && er.syscall === 'realpath' && (
18 er.code === 'ELOOP' ||
19 er.code === 'ENOMEM' ||
20 er.code === 'ENAMETOOLONG'
24 function realpath (p, cache, cb) {
26 return origRealpath(p, cache, cb)
29 if (typeof cache === 'function') {
33 origRealpath(p, cache, function (er, result) {
35 old.realpath(p, cache, cb)
42 function realpathSync (p, cache) {
44 return origRealpathSync(p, cache)
48 return origRealpathSync(p, cache)
51 return old.realpathSync(p, cache)
58 function monkeypatch () {
59 fs.realpath = realpath
60 fs.realpathSync = realpathSync
63 function unmonkeypatch () {
64 fs.realpath = origRealpath
65 fs.realpathSync = origRealpathSync