Permalink
Cannot retrieve contributors at this time
66 lines (57 sloc)
1.28 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/fs.realpath/index.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = realpath | |
realpath.realpath = realpath | |
realpath.sync = realpathSync | |
realpath.realpathSync = realpathSync | |
realpath.monkeypatch = monkeypatch | |
realpath.unmonkeypatch = unmonkeypatch | |
var fs = require('fs') | |
var origRealpath = fs.realpath | |
var origRealpathSync = fs.realpathSync | |
var version = process.version | |
var ok = /^v[0-5]\./.test(version) | |
var old = require('./old.js') | |
function newError (er) { | |
return er && er.syscall === 'realpath' && ( | |
er.code === 'ELOOP' || | |
er.code === 'ENOMEM' || | |
er.code === 'ENAMETOOLONG' | |
) | |
} | |
function realpath (p, cache, cb) { | |
if (ok) { | |
return origRealpath(p, cache, cb) | |
} | |
if (typeof cache === 'function') { | |
cb = cache | |
cache = null | |
} | |
origRealpath(p, cache, function (er, result) { | |
if (newError(er)) { | |
old.realpath(p, cache, cb) | |
} else { | |
cb(er, result) | |
} | |
}) | |
} | |
function realpathSync (p, cache) { | |
if (ok) { | |
return origRealpathSync(p, cache) | |
} | |
try { | |
return origRealpathSync(p, cache) | |
} catch (er) { | |
if (newError(er)) { | |
return old.realpathSync(p, cache) | |
} else { | |
throw er | |
} | |
} | |
} | |
function monkeypatch () { | |
fs.realpath = realpath | |
fs.realpathSync = realpathSync | |
} | |
function unmonkeypatch () { | |
fs.realpath = origRealpath | |
fs.realpathSync = origRealpathSync | |
} |