How to use the graceful-fs.stat 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 angelozerr / tern.java / eclipse / tern.eclipse.ide.server.nodejs.embed.linux.gtk.x86 / nodejs / node-v0.10.22-linux-x86 / lib / node_modules / npm / lib / cache.js View on Github external
var dist = data.dist

    if (!dist) return cb(new Error("No dist in "+data._id+" package"))

    if (!dist.tarball) return cb(new Error(
      "No dist.tarball in " + data._id + " package"))

    if ((response && response.statusCode !== 304) || npm.config.get("force")) {
      return fetchit()
    }

    // we got cached data, so let's see if we have a tarball.
    var pkgroot = path.join(npm.cache, name, ver)
    var pkgtgz = path.join(pkgroot, "package.tgz")
    var pkgjson = path.join(pkgroot, "package", "package.json")
    fs.stat(pkgtgz, function (er, s) {
      if (!er) {
        readJson(pkgjson, function (er, data) {
          er = needName(er, data)
          er = needVersion(er, data)
          if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR")
            return cb(er)
          if (er) return fetchit()
          return cb(null, data)
        })
      } else return fetchit()
    })

    function fetchit () {
      if (!npm.config.get("registry")) {
        return cb(new Error("Cannot fetch: "+dist.tarball))
      }
github nullivex / nodist / bin / node_modules / npm / lib / npm.js View on Github external
mkdirp(p, function (er, made) {
    // it could be that we couldn't create it, because it
    // already exists, and is on a read-only fs.
    if (er) {
      return fs.stat(p, function (er2, st) {
        if (er2 || !st.isDirectory()) return cb(er)
        return cb(null, made)
      })
    }
    return cb(er, made)
  })
}
github cocos-creator / firedoc / lib / files.js View on Github external
function copyDirectory(source, dest, overwrite, callback) {
    // Allow callback as third arg.
    if (typeof overwrite === 'function') {
      callback = overwrite;
      overwrite = null;
    }

    fs.stat(source, afterSourceStat);

    function afterSourceStat(err, stats) {
      if (err) {
        return callback(err);
      }

      if (!stats.isDirectory()) {
        return callback(new Error("Source is not a directory: " + source));
      }
      fs.lstat(dest, afterDestStat);
    }

    function afterDestStat(err, stats) {
      if (err && err.code !== 'ENOENT') {
        return callback(err);
      }
github enyojs / ares-project / hermes / fsLocal.js View on Github external
FsLocal.prototype._propfind = function(err, relPath, depth, next) {
	if (err) {
		setImmediate(next, err);
		return;
	}

	var localPath = path.join(this.root, relPath),
            urlPath = this.normalize(relPath);
	if (path.basename(relPath).charAt(0) ===".") {
		// Skip hidden files & folders (using UNIX
		// convention: XXX do it for Windows too)
		setImmediate(next);
		return;
	}

	fs.stat(localPath, (function(err, stat) {
		if (err) {
			setImmediate(next, err);
			return;
		}

		// minimum common set of properties
		var node = {
			path: urlPath,
			name: path.basename(urlPath),
			id: this.encodeFileId(urlPath),
			isDir: stat.isDirectory()
		};

		// Give the top-level node the name (NOT the path) of the mount-point
		if (node.name === '') {
			node.name = path.basename(this.root);
github othiym23 / packard / test / metadata-read-flac.js View on Github external
makeAlbum.then(function (paths) {
    t.equal(paths.length, 1)
    stat(paths[0], function (er, stats) {
      if (er) throw er
      createReadStream(paths[0]).pipe(reader(
        { path: paths[0], stats: stats },
        new Map(),
        function (info) {
          var track = info.track
          t.ok(track, 'should get back a track')
          t.equal(track.file.path, paths[0])
          t.equal(track.tags.artist, 'The Necks')
          t.equal(track.tags.album, 'Open')
          t.equal(track.tags.title, 'Open')
          t.equal(track.date, '2012-01-20')
          t.equal(track.index, 1)
          t.end()
        },
        function (er) {
github alan-ai / alan-sdk-reactnative / testtools / node_modules / @expo / config / node_modules / @react-native-community / cli-platform-android / node_modules / fs-extra / lib / util / stat.js View on Github external
function getStats (src, dest, cb) {
  if (nodeSupportsBigInt()) {
    fs.stat(src, { bigint: true }, (err, srcStat) => {
      if (err) return cb(err)
      fs.stat(dest, { bigint: true }, (err, destStat) => {
        if (err) {
          if (err.code === 'ENOENT') return cb(null, { srcStat, destStat: null })
          return cb(err)
        }
        return cb(null, { srcStat, destStat })
      })
    })
  } else {
    fs.stat(src, (err, srcStat) => {
      if (err) return cb(err)
      fs.stat(dest, (err, destStat) => {
        if (err) {
          if (err.code === 'ENOENT') return cb(null, { srcStat, destStat: null })
          return cb(err)
github componentjs / resolver.js / lib / installer.js View on Github external
return function (done) {
    fs.stat(filename, done)
  }
}
github gobblejs / gobble / lib / file / ls.js View on Github external
files.forEach( function ( filename ) {
				var filepath = dir + path.sep + filename;

				fs.stat( filepath, function ( err, stats ) {
					if ( err ) return cb( err );

					if ( stats.isDirectory() ) {
						processDir( filepath, function ( err, filepaths ) {
							if ( err ) return cb( err );

							result.push.apply( result, filepaths );
							check();
						});
					} else {
						result.push( filepath );
						check();
					}
				});
			});
		});
github enyojs / ares-project / hermes / fsLocal.js View on Github external
function _copyNode(srcPath, dstPath, next) {
		fs.stat(srcPath, function(err, stats) {
			if (err) {
				setImmediate(next, err);
				return;
			}
			if (stats.isDirectory()) {
				_copyDir(srcPath, dstPath, next);
			} else if (stats.isFile()){
				copyFile(srcPath, dstPath, next);
			}
		});
	}
	function _copyDir(srcPath, dstPath, next) {
github aikar / timings / node_modules / node-sass / node_modules / pangyp / lib / configure.js View on Github external
function guessPython () {
    log.verbose('could not find "' + python + '". guessing location')
    var rootDir = process.env.SystemDrive || 'C:\\'
    if (rootDir[rootDir.length - 1] !== '\\') {
      rootDir += '\\'
    }
    var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe')
    log.verbose('ensuring that file exists:', pythonPath)
    fs.stat(pythonPath, function (err, stat) {
      if (err) {
        if (err.code == 'ENOENT') {
          failNoPython()
        } else {
          callback(err)
        }
        return
      }
      python = pythonPath
      checkPythonVersion()
    })
  }