How to use the statSync function from fs-extra
Find comprehensive JavaScript fs-extra.statSync code examples handpicked from public code repositorys.
527 528 529 530 531 532 533 534 535
var dirs = []; try { rootpath = path.normalize(rootpath || srcpath); fs.readdirSync(srcpath).forEach((file) => { var fullname = path.join(srcpath, file); var fstat = fs.statSync(fullname); if (fstat.isDirectory()) { var packName = fullname;
82
94
26
+ 19 other calls in file
139 140 141 142 143 144 145 146 147 148
it('can write large documents', function(done) { partition.open(); let blob = 'foobar'.repeat(100000); partition.write(blob, () => { let stat = fs.statSync('test/data/.part'); expect(stat.size).to.be.greaterThan(blob.length); done(); }); });
4
31
0
+ 5 other calls in file
GitHub: bcomnes/cpx2
29 30 31 32 33 34 35 36 37 38 39
module.exports = function copyFileSync(source, output, options) { const stat = fs.statSync(source) if (options.update) { try { const dstStat = fs.statSync(output) if (dstStat.mtime.getTime() > stat.mtime.getTime()) { // Don't overwrite because the file on destination is newer than // the source file. return
3
28
0
+ 3 other calls in file
GitHub: microsoft/devicescript
8 9 10 11 12 13 14 15 16 17 18
let watch = false let fast = false function getMTime(path) { try { const st = fs.statSync(path) return st.mtimeMs } catch { return undefined }
4
24
9
GitHub: volumio/volumio3-backend
2446 2447 2448 2449 2450 2451 2452 2453 2454 2455
} else { isofile = true; } } else { try { var stat = libFsExtra.statSync(uri); } catch (err) { self.logger.error("scanFolder - failure to stat '" + uri + "'"); return uris; }
28
21
4
5064 5065 5066 5067 5068 5069 5070 5071 5072 5073
for (var i = 0; i < ev1.length; i++) { /// Get all the file information var itemPath = ev1[i].path; var itemName = path.parse(itemPath).base; var duplicate = false; var statsObj = fs.statSync(itemPath); // check for duplicate or files with the same name for (var j = 0; j < ev2.children.length; j++) { if (itemName === ev2.children[j].innerText) { duplicate = true;
9
22
9
+ 69 other calls in file
542 543 544 545 546 547 548 549 550 551
// Collect some info regarding the MODDABLE toolkit // https://stackoverflow.com/questions/18112204/get-all-directories-within-directory-nodejs function getDirectories(parent_dir) { return fs.readdirSync(parent_dir).filter(function (file) { return fs.statSync(path.join(parent_dir,file)).isDirectory(); }); } {
6
21
3
+ 19 other calls in file
GitHub: zhangfisher/voerka-i18n
131 132 133 134 135 136 137 138 139 140 141
} } function fileIsExists(filename){ try{ fs.statSync(filename) return true }catch(e){ return false }
3
24
3
GitHub: GAMS-dev/miro
453 454 455 456 457 458 459 460 461 462
title: lang.main.ErrorLogoHdr, message: lang.main.ErrorLogoMultiMsg, }); return; } const logoSize = fs.statSync(filteredPath[0]).size / 1000000.0; if (logoSize > 10) { log.info(`App logo not valid due to file size being too large (${logoSize}MB)`); showErrorMsg({ type: 'info',
1
7
0
190 191 192 193 194 195 196 197 198 199
}; let getLocalFile = (dir, fn) => { let file = path.join(dir, fn); try { let packageFile = fs.readJsonSync(path.join(dir, "package.json")); fs.statSync(file.replace(/\.js$/, ".html")); return { path: dir, name: packageFile.name };
0
2
0
+ 3 other calls in file
GitHub: stevekeol/DApp-Hangzhou
302 303 304 305 306 307 308 309 310 311
return true } else { var count = 0 paths.forEach(function (p) { p = path.join(dirname, p) var stat = fs.statSync(p) if (stat.isDirectory()) { if (self.rmEmptyDirsSync(p)) { count++ }
0
2
0
7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500
} function createFileSync (file) { let stats try { stats = fs.statSync(file) } catch (e) {} if (stats && stats.isFile()) return const dir = path.dirname(file)
0
1
0
+ 35 other calls in file
GitHub: davidmerfield/Blot
178 179 180 181 182 183 184 185 186 187
}) .filter(function (path) { return ( basename(path)[0] !== "-" && basename(path)[0] !== "." && fs.statSync(path).isDirectory() ); }); callback(null, folders);
69
0
23
+ 4 other calls in file
GitHub: davidmerfield/Blot
50 51 52 53 54 55 56 57 58 59
let cancelled; try { size = prettySize( Math.round( fs.statSync(join(tempDir, "import", req.blog.id, i, "result.zip")) .size / 1000 ) ); } catch (e) {}
69
0
23
+ 4 other calls in file
GitHub: nyx-bot/Nyx
249 250 251 252 253 254 255 256 257 258
ran++; log.sysLog(`Starting Nyx... {${ran}}`); const i = await runProc(); log.sysLog(`Exited with code ${i}`); const lastUpdated = fs.statSync(`./index.js`).mtimeMs; if(lastUpdated > beginningUpdated) { log.sysWarn(`The index script has been updated ever since it was ran.`); log.sysLog(`Quitting host process to apply the update!`); process.exit(0) };
1
4
1
+ 5 other calls in file
GitHub: GetPublii/Publii
188 189 190 191 192 193 194 195 196 197
// Remove theme dir let themeDirStat = false; try { themeDirStat = fs.statSync(path.join(this.sitePath, themeToRemove)); } catch(e) {} if(themeDirStat && themeDirStat.isDirectory()) { // If yes - remove it
341
0
79
+ 9 other calls in file
GitHub: GetPublii/Publii
94 95 96 97 98 99 100 101 102
// Move images from the temp directory let tempDirectoryExists = true; let tempImagesDir = path.join(this.siteDir, 'input', 'media', 'tags', 'temp'); try { fs.statSync(tempImagesDir).isDirectory(); } catch (err) { tempDirectoryExists = false; }
341
0
79
+ 9 other calls in file
GitHub: 0neGal/viper
53 54 55 56 57 58 59 60 61 62
} let files = fs.readdirSync(mods.path); files.forEach((file) => { // return early if `file` isn't a folder if (! fs.statSync(path.join(mods.path, file)).isDirectory()) { return; } let modjson = path.join(mods.path, file, "mod.json");
17
106
4
+ 53 other calls in file
3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264
DataPacksJob.prototype.rmdirCustom = async function (dir) { var list = fs.readdirSync(dir); for (var i = 0; i < list.length; i++) { var filename = path.join(dir, list[i]); var stat = fs.statSync(filename); if (filename == "." || filename == "..") { // pass these files } else if (stat.isDirectory()) {
80
94
26
+ 17 other calls in file
306 307 308 309 310 311 312 313 314 315
console.error(err) res.status(400).json({error: err}); } else { const cacheFile = path.join(CACHE_PATH, `${cacheId}`); mergeFiles(partFiles, cacheFile).then((status) => { const cacheFileSize = fs.statSync(cacheFile).size; if (cacheFileSize !== size) { const err = `Uploaded size mismatch: received ${cacheFileSize} expected ${size}`; console.error(err) res.status(400).json({error: err});
6
30
1
+ 3 other calls in file
fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)