How to use the statAsync function from fs

Find comprehensive JavaScript fs.statAsync code examples handpicked from public code repositorys.

92
93
94
95
96
97
98
99
100
101
// locking the file to prevent paralel writes
lockfile.lockAsync(lock, {
  stale: 10000,
  wait: 5000
}).then(() => {
  return fs.statAsync(self.path)
}).catch((err) => {
  // if no entry, file has been moved or removed keep going
  if (err.code === "ENOENT") {
    return null // file has been moved or removed. force a re-open.
fork icon1
star icon1
watch icon0

+ 3 other calls in file

31
32
33
34
35
36
37
38
39
40
41


// Server.js
// Returns true if successful or false otherwise
async function checkCreateUploadsFolder(uploadsFolder) {
  try {
    await fs.statAsync(uploadsFolder);
  } catch (e) {
    if (e && e.code == "ENOENT") {
      console.log("The uploads folder doesn't exist, creating a new one...");
      try {
fork icon0
star icon0
watch icon0