How to use the fs.stat function in fs

To help you get started, we’ve selected a few 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 intervalia / gulp-component-assembler / src / hasChanged.js View on Github external
function compareLastModifiedTime(stream, cb, basePath, sourceFile, targetPath) {
  if (sourceFile.isNull()) {
    cb(null, sourceFile);
    return;
  }

  fs.stat(targetPath, function(err, targetStat) {
    if (err) {
      if (err.code === 'ENOENT') {
        // try reading the file using the oldDest path
        var target = path.join(basePath, path.basename(basePath)+'.js');

        if (target !== targetPath) {
          return compareLastModifiedTime(stream, cb, basePath, sourceFile, target);
        }
        else {
          stream.push(sourceFile);
        }
      }
      else {
        stream.emit('error', new gutil.PluginError('gulp-changed', err, {
          fileName: sourceFile.path
        }));
github domharrington / fileupload / lib / modules / file.js View on Github external
function (callback) {
      fs.stat(uploadDir, function (error) {
        // Deliberately passing error to next function for checking
        callback(null, error)
      })
    },
    function (error, callback) {
github chill117 / proxy-verifier / scripts / update-data.js View on Github external
openedZipArchive.openReadStream(entry, function(error, readStream) {

					if (error) {
						return done(error);
					}

					var file = path.join(tmpDir, fileName);

					fs.stat(file, function(error, stat) {

						if (!error && program.debug) {
							// File already exists.
							return done(null, fileName);
						}

						readStream.pipe(fs.createWriteStream(file))
							.on('error', cb)
							.on('close', function() {
								done(null, fileName);
							});
					});
				});
			}
github mikeal / filed / main.js View on Github external
return
      }

      // Destination is not an HTTP request

      if (self.src && !self.dest) {
        stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
      } else if (self.dest && !self.src) {
        fs.createReadStream(self.path).pipe(self.dest)
      }
    }

    if (!err && stats.isDirectory()) {
      self.path = path.join(self.path, self.index)
      self.mimetype = mime.getType(self.path.slice(self.path.lastIndexOf('.')+1))
      fs.stat(self.path, finish)
      return
    } else {
      finish(err, stats)
    }
    
    if (!self.src && !self.dest) {
      if (self.buffers.length > 0) {
        stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
      } else if (self.listeners('data').length > 0) {
        fs.createReadStream(self.path).pipe(self.dest)
      } else {
        fs.createReadStream(self.path).pipe(self)
      }
    }

  })
github hubtel / ussd-mocker / node_modules / express / node_modules / send / index.js View on Github external
function next(err) {
    if (self._extensions.length <= i) {
      return err
        ? self.onStatError(err)
        : self.error(404)
    }

    var p = path + '.' + self._extensions[i++]

    debug('stat "%s"', p)
    fs.stat(p, function (err, stat) {
      if (err) return next(err)
      if (stat.isDirectory()) return next()
      self.emit('file', p, stat)
      self.send(p, stat)
    })
  }
}
github lloiser / go-debug / lib / main.js View on Github external
return new Promise((resolve, reject) => {
          FS.stat(dir, (err) => err ? reject(err) : resolve())
        }).then(() => {
          return watchPath(dir, {}, (events) => {
github OfficeDev / office-js-snippets / config / helpers.ts View on Github external
new Promise((resolve, reject) => {
        fs.stat(path, (err, file) => {
            if (err) {
                return reject(err);
            }
            return resolve(file.isDirectory());
        });
    });
github latentflip / building-static-server / plugin.js View on Github external
function isFileOlderThan(f, timestamp, done) {
    fs.stat(f, function (err, stat) {
        if (err) { return done(err); }
        return done(null, stat.mtime < timestamp);
    });
}
github kanso / kanso / node_modules / watch / main.js View on Github external
nfiles.forEach(function (b) {
              var file = path.join(f, b);
              if (!files[file]) {
                fs.stat(file, function (err, stat) {
                  callback(file, stat, null);
                  files[file] = stat;
                  fileWatcher(file);
                })
              }
            })
          })
github johntitus / node-horseman / lib / actions.js View on Github external
return HorsemanPromise.fromCallback(function(done) {
				return fs.stat(path, done);
			});
		})

fs

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

70 / 100
Full package analysis