How to use the stat function from fs-promise

Find comprehensive JavaScript fs-promise.stat code examples handpicked from public code repositorys.

76
77
78
79
80
81
82
83
84
85
if (fileExtension === undefined) {
  return;
}
const name = `${filename.split(`_${uuid}`)[0]}.${filename.split('.')[1]}`;
const filePath = `${basedir}/${filename}`;
const fileStats = await fs.stat(filePath);
const dateChanged = fileStats.ctime;

const fileObject = {
  uuid,
fork icon20
star icon26
watch icon0

+ 5 other calls in file

60
61
62
63
64
65
66
67
68
69
CachedDir.prototype.resolveEntry = function(name) {
  var value = this.cache[name], self = this
  if (!value) return Promise.resolve(null)
  if (value == dummy) {
    var fullName = this.path + "/" + name
    return fs.stat(fullName).then(function(stats) {
      if (stats.isDirectory())
        return self.cache[name] = new CachedDir(fullName, stats, self.mount)
      if (stats.isFile())
        return self.cache[name] = new CachedFile(fullName, stats, self.mount)
fork icon3
star icon39
watch icon0

45
46
47
48
49
50
51
52
53
}

/* --- Generates java func data, if this lang needs any --- */
const make_java_func_data = async () => {
  if (needs_java_func_data) {
    await fs.stat(config.build_path + '/java_func_data')
        .catch(expect_error('ENOENT', java_func_data_generator));
  }
}
fork icon0
star icon1
watch icon11

182
183
184
185
186
187
188
189
190
191

  if( typeof something === 'string' ) {
    if( path.basename(something) === '.oathframe.json' )
      return resolve(path.dirname(something));

    return fs.stat(something).then(stat => (stat.isDirectory() ? createDirectory : createFile)(something));
  }

  throw new Error('Resource: not sure how to resolve ' + something);
});
fork icon0
star icon1
watch icon0

60
61
62
63
64
65
66
67
68
 * @param {string[]} elements
 * @returns {Promise<string[]>}
 */
function filterDirs(elements) {
    return promiseFilter(elements, element => {
        return fs.stat(path.join(baseDir, element))
            .then(stats => stats.isDirectory());
    });
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file