Sha256: 2e334ba43cd4852f7a3ed68159029167c05d7fa6af536e6ef177eb868ccd1bb8

Contents?: true

Size: 1.28 KB

Versions: 300

Compression:

Stored size: 1.28 KB

Contents

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
}

Version data entries

300 entries across 276 versions & 35 rubygems

Version Path
rapid_stack-0.2.0 templates/frontend/node_modules/fs.realpath/index.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/fs.realpath/index.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.60 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.59 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.58 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.57 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.56 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.55 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.54 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.53 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.52 node_modules/fs.realpath/index.js
trusty-cms-6.3.1 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.51 node_modules/fs.realpath/index.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.50 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.49 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.48 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.47 node_modules/fs.realpath/index.js
immosquare-cleaner-0.1.46 node_modules/fs.realpath/index.js