How to use the graceful-fs.lstat function in graceful-fs

To help you get started, we’ve selected a few graceful-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gulpjs / vinyl-fs / lib / file-operations.js View on Github external
function reflectLinkStat(path, file, callback) {
  // Set file.stat to the reflect current state on disk
  fs.lstat(path, onLstat);

  function onLstat(lstatErr, stat) {
    if (lstatErr) {
      return callback(lstatErr);
    }

    file.stat = stat;
    callback();
  }
}
github cocos-creator / firedoc / lib / files.js View on Github external
function copyFile(source, dest, overwrite, callback) {
    // Allow callback as third arg.
    if (typeof overwrite === 'function') {
      callback = overwrite;
      overwrite = null;
    }

    fs.lstat(source, function (err, sourceStats) {
      if (err) {
        return callback(err);
      }

      if (!sourceStats.isFile()) {
        return callback(new Error("Source is not a file: " + source));
      }

      fs.lstat(dest, function (err, destStats) {
        var rs;

        if (err && err.code !== 'ENOENT') {
          return callback(err);
        }

        if (destStats) {
github liquidg3 / altair / node_modules / npm / lib / utils / gently-rm.js View on Github external
function readLinkOrShim (path, cb) {
  validate('SF', arguments)
  lstat(path, iferr(cb, function (stat) {
    if (stat.isSymbolicLink()) {
      readlink(path, cb)
    } else {
      readCmdShim(path, function (er, source) {
        if (!er) return cb(null, source)
        // lstat wouldn't return an error on these, so we don't either.
        if (er.code === 'ENOTASHIM' || er.code === 'EISDIR') {
          return cb(null, null)
        } else {
          return cb(er)
        }
      })
    }
  }))
}
github 3rd-Eden / canihaz / node_modules / npm / lib / install.js View on Github external
function checkGit (folder, cb) {
  // if it's a git repo then don't touch it!
  fs.lstat(folder, function (er, s) {
    if (er || !s.isDirectory()) return cb()
    else checkGit_(folder, cb)
  })
}
github cocos-creator / firedoc / lib / files.js View on Github external
fs.lstat(source, function (err, sourceStats) {
      if (err) {
        return callback(err);
      }

      if (!sourceStats.isFile()) {
        return callback(new Error("Source is not a file: " + source));
      }

      fs.lstat(dest, function (err, destStats) {
        var rs;

        if (err && err.code !== 'ENOENT') {
          return callback(err);
        }

        if (destStats) {
          if (overwrite) {
            deletePath(dest); // TODO: make this async
          } else {
            callback(new Error("Destination already exists: " + dest));
            return;
          }
        }

        rs = fs.createReadStream(source);
github graalvm / graaljs / deps / npm / lib / utils / read-installed.js View on Github external
if (er) i = []
    installed = i.filter(function (f) { return f.charAt(0) !== "." })
    next()
  })

  readJson(path.resolve(folder, "package.json"), function (er, data) {
    obj = copy(data)

    if (!parent) {
      obj = obj || true
      er = null
    }
    return next(er)
  })

  fs.lstat(folder, function (er, st) {
    if (er) {
      if (!parent) real = true
      return next(er)
    }
    fs.realpath(folder, function (er, rp) {
      //console.error("realpath(%j) = %j", folder, rp)
      real = rp
      if (st.isSymbolicLink()) link = rp
      next(er)
    })
  })

  var errState = null
    , called = false
  function next (er) {
    if (errState) return
github davidhealey / waistline / node_modules / npm / node_modules / fs-vacuum / vacuum.js View on Github external
function vacuum (leaf, options, cb) {
  assert(typeof leaf === 'string', 'must pass in path to remove')
  assert(typeof cb === 'function', 'must pass in callback')

  if (!options) options = {}
  assert(typeof options === 'object', 'options must be an object')

  var log = options.log ? options.log : function () {}

  leaf = leaf && resolve(leaf)
  var base = options.base && resolve(options.base)
  if (base && !isInside(leaf, base)) {
    return cb(new Error(leaf + ' is not a child of ' + base))
  }

  lstat(leaf, function (error, stat) {
    if (error) {
      if (error.code === 'ENOENT') return cb(null)

      log(error.stack)
      return cb(error)
    }

    if (!(stat && (stat.isDirectory() || stat.isSymbolicLink() || stat.isFile()))) {
      log(leaf, 'is not a directory, file, or link')
      return cb(new Error(leaf + ' is not a directory, file, or link'))
    }

    if (options.purge) {
      log('purging', leaf)
      rimraf(leaf, function (error) {
        if (error) return cb(error)
github liquidg3 / altair / node_modules / npm / lib / utils / lifecycle.js View on Github external
function checkForLink (pkg, cb) {
  var f = path.join(npm.dir, pkg.name)
  fs.lstat(f, function (er, s) {
    cb(null, !(er || !s.isSymbolicLink()))
  })
}
github MindFreakers / cdn / node_modules / fs-extra / lib / copy / ncp.js View on Github external
function isWritable (path, done) {
    fs.lstat(path, function (err) {
      if (err) {
        if (err.code === 'ENOENT') return done(true)
        return done(false)
      }
      return done(false)
    })
  }
github davidhealey / waistline / node_modules / npm / lib / utils / lifecycle.js View on Github external
function checkForLink (pkg, cb) {
  var f = path.join(npm.dir, pkg.name)
  fs.lstat(f, function (er, s) {
    cb(null, !(er || !s.isSymbolicLink()))
  })
}