How to use the graceful-fs.lstatSync 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 Financial-Times / polyfill-service / tasks / node / buildsources.js View on Github external
function flattenPolyfillDirectories(directory) {
	// Recursively discover all subfolders and produce a flattened list.
	// Directories prefixed with '__' are not polyfill features and are not included.
	let results = [];
	for (const item of fs.readdirSync(directory)) {
		const joined = path.join(directory, item);
		if (fs.lstatSync(joined).isDirectory() && item.indexOf('__') !== 0) {
			results = results
				.concat(flattenPolyfillDirectories(joined))
				.concat(joined);
		}
	}
	return results;
}
github npm / write-file-atomic / test / integration.js View on Github external
test('writes to symlinks without clobbering (sync)', function (t) {
  t.plan(4)
  var file = tmpFile()
  var link = tmpFile()
  fs.writeFileSync(file, '42')
  fs.symlinkSync(file, link)
  didWriteFileAtomicSync(t, currentUser(), link, '43')
  t.is(readFile(file), '43', 'target content ok')
  t.is(readFile(link), '43', 'link content ok')
  t.ok(fs.lstatSync(link).isSymbolicLink(), 'link is link')
})
github update / update / test / app.symlink.js View on Github external
var onEnd = function(){
      buffered.length.should.equal(1);
      buffered[0].should.equal(expectedFile);
      buffered[0].cwd.should.equal(__dirname, 'cwd should have changed');
      buffered[0].base.should.equal(expectedBase, 'base should have changed');
      buffered[0].path.should.equal(expectedPath, 'path should have changed');
      fs.readlinkSync(expectedPath).should.equal(inputPath);
      fs.lstatSync(expectedPath).isDirectory().should.equal(false);
      fs.statSync(expectedPath).isDirectory().should.equal(true);
      done();
    };
github generate / generate / test / dest.js View on Github external
var onEnd = function(){
      expectedCount.should.equal(1);
      assert(!chmodSpy.called);
      realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode);
      done();
    };
github gulpjs / vinyl-fs / test / dest.js View on Github external
function assert(files) {
      var stats = fs.lstatSync(outputPath);

      expect(files.length).toEqual(1);
      expect(files).toInclude(file);
      expect(stats.size).toEqual(size);
    };
github assemble / assemble / test / app.dest.js View on Github external
var onEnd = function(){
      masked(fs.lstatSync(expectedBase).mode).should.equal(expectedDirMode);
      masked(buffered[0].stat.mode).should.equal(expectedFileMode);
      cb();
    };
github katiefenn / parker / parker.js View on Github external
var read = function (filePath, onFileLoad, onAllLoad) {
    if (fs.lstatSync(filePath).isDirectory()) {
        readDirectory(filePath, onFileLoad, onAllLoad);
    }
    else if (fileIsStylesheet(filePath)) {
        readFile(filePath, function (err, data) {
            onFileLoad(err, data);
            onAllLoad();
        });
    } else {
        onAllLoad();
    }
}
github jprichardson / node-fs-extra / lib / copy-sync / copy-file-sync.js View on Github external
function copyFileSync (srcFile, destFile, options) {
  const overwrite = options.overwrite
  const errorOnExist = options.errorOnExist
  const preserveTimestamps = options.preserveTimestamps

  if (fs.existsSync(destFile)) {
    if (overwrite) {
      fs.unlinkSync(destFile)
    } else if (errorOnExist) {
      throw new Error(`${destFile} already exists`)
    } else return
  }

  if (typeof fs.copyFileSync === 'function') {
    fs.copyFileSync(srcFile, destFile)
    const st = fs.lstatSync(srcFile)
    fs.chmodSync(destFile, st.mode)
    if (preserveTimestamps) utimesSync(destFile, st.atime, st.mtime)
    return undefined
  }
  return copyFileSyncFallback(srcFile, destFile, preserveTimestamps)
}
github shama / gaze / lib / pathwatcher.js View on Github external
function markDir(file) {
  if (file.slice(-1) !== path.sep) {
    if (fs.lstatSync(file).isDirectory()) {
      file += path.sep;
    }
  }
  return file;
}
github onmyway133 / PushNotifications / node_modules / fs-extra / lib / ensure / link.js View on Github external
function createLinkSync (srcpath, dstpath, callback) {
  var destinationExists = fs.existsSync(dstpath)
  if (destinationExists) return undefined

  try {
    fs.lstatSync(srcpath)
  } catch (err) {
    err.message = err.message.replace('lstat', 'ensureLink')
    throw err
  }

  var dir = path.dirname(dstpath)
  var dirExists = fs.existsSync(dir)
  if (dirExists) return fs.linkSync(srcpath, dstpath)
  mkdir.mkdirsSync(dir)

  return fs.linkSync(srcpath, dstpath)
}