How to use the exists function from fs

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

102
103
104
105
106
107
108
109
110
111
name = `${name}`;

return new IAsyncOperation((res, rej) => {
    this.ensureInitialised().then(_ => {
        var filePath = _path.join(this.path, name);
        fs.exists(filePath, (exists: boolean) => {
            if (exists) {
                if (collision == CreationCollisionOption.failIfExists) {
                    rej();
                    return;
fork icon1
star icon12
watch icon3

+ 7 other calls in file

110
111
112
113
114
115
116
117
118
119

async.waterfall([
  async.apply(HelperFS.createFolderIfNotExists, cmsfiles_folder),
  async.apply(HelperFS.clearFiles, public_folder, jsh.Config.public_temp_expiration, -1),
  function (callback) {
    fs.exists(cmsfiles_folder + file_orig_name, function (exists) {
      if (exists) return callback({ number: -37, message: 'File already exists' });
      else return callback(null);
    });
  },
fork icon5
star icon5
watch icon2

69
70
71
72
73
74
75
76
77
78
    "frontend",
    "build/images",
    name + ".jpg"
);
//CHECK  EXISTING IMG
Fs.exists(path, function (exists) {
    if (!exists) {
        return downloadImage(userPic, name);
    }
});
fork icon0
star icon0
watch icon1

+ 2 other calls in file

16
17
18
19
20
21
22
23
24
25
 * @param {string} filename
 * @returns {Promise.<boolean>}
 */
async existsAsync(filename) {
  return new Promise((resolve) =>
    fs.exists(filename, (exists) => resolve(exists))
  )
},

/**
fork icon0
star icon0
watch icon2