How to use the lstatSync function from fs
Find comprehensive JavaScript fs.lstatSync code examples handpicked from public code repositorys.
GitHub: zhuzhuyule/HexoEditor
57 58 59 60 61 62 63 64 65 66
} } static isDirectory(fileName) { try { return fs.lstatSync(fileName).isDirectory(); } catch (e) { return false; } }
156
0
32
+ 15 other calls in file
GitHub: NEIAPI/nei-toolkit
216 217 218 219 220 221
* @param {string} dir - directory path * @return {boolean} is directory */ exports.isdir = function (dir) { try { return fs.lstatSync(dir).isDirectory();
124
815
42
+ 30 other calls in file
GitHub: blockcollider/bcnode
60 61 62 63 64 65 66 67 68 69
exports.lchown = co.promisify(fs.lchown); exports.lchownSync = fs.lchownSync; exports.link = co.promisify(fs.link); exports.linkSync = fs.linkSync; exports.lstat = co.promisify(fs.lstat); exports.lstatSync = fs.lstatSync; exports.mkdir = co.promisify(fs.mkdir); exports.mkdirSync = fs.mkdirSync; exports.mkdtemp = co.promisify(fs.mkdtemp); exports.mkdtempSync = fs.mkdtempSync;
22
45
26
685 686 687 688 689 690 691 692 693 694
if (mkParent) return this[ONERROR](mkParent, entry) } } const [lstatEr, st] = callSync(() => fs.lstatSync(entry.absolute)) if (st && (this.keep || this.newer && st.mtime > entry.mtime)) return this[SKIP](entry) if (lstatEr || this[ISREUSABLE](entry, st))
3
2
0
GitHub: LabsRS-Dev/AiEXifCool
29 30 31 32 33 34 35 36 37 38
if (options.root) { this.root = options.root } else { try { sysFS.lstatSync('./public') this.root = './public' } catch (err) { this.root = './' }
2
11
11
58 59 60 61 62 63 64 65 66 67
if(!fs.existsSync(modelbasedir)){ _this.LogInit_ERROR('Model folder ' + modelbasedir + ' not found'); return; } var fmodels = fs.readdirSync(modelbasedir); for (let i in fmodels) { var fname = fmodels[i]; var fpath = modelbasedir + fname; var fstat = fs.lstatSync(fpath); if(fstat.isDirectory()){ if(options.isBaseDir){ if(fname=='js') continue; if(fname=='sql') continue;
5
5
2
63 64 65 66 67 68 69 70 71 72
folder_list = []; file_list = []; files.forEach(function (file) { const filePath = d + "/" + file; const fileStat = fs.lstatSync(filePath); if (fileStat.isDirectory()) { folder_list.push(file); } else {
1
2
1
+ 3 other calls in file
GitHub: AxelRothe/wranglebot
282 283 284 285 286 287 288 289 290 291
* Gets file stats * @param pathToElement * @returns {*} */ lstatSync(pathToElement) { return fs.lstatSync(pathToElement); } createReadStream(pathToElement, options) { return fs.createReadStream(pathToElement, options);
0
4
2
84 85 86 87 88 89 90 91 92 93
// Checks that a given filename is valid function checkFileStr (str, ref) { if (typeof(str) != "string" || str == "") { throw new userError(`The value of ${ref} is invalid. \nFix the value, or remove the attribute if you do not intend to use it.`); } if (!(fs.existsSync(str) && fs.lstatSync(str).isFile())) { let fileStr = str[0] == "/" ? str : `${__dirname}/${str}` throw new userError(`${ref}: File "${fileStr}" does not exist.`); } }
0
2
2
+ 3 other calls in file
43 44 45 46 47 48 49 50 51 52
* to one string. * @param {String} filePath */ const readComponentCode = filePath => { let code = ''; const isItFolder = fs.lstatSync(filePath).isDirectory(); if (isItFolder) { const contents = fs.readdirSync(filePath); contents.forEach(file => { code += readComponentCode(path.join(filePath + '/' + file));
0
1
0
+ 3 other calls in file
GitHub: liihuu/KLineChart
28 29 30 31 32 33 34 35 36 37
const files = fs.readdirSync(folder); const htmls = []; for (var i = 0; i < files.length; i++) { var filename = path.join(folder, files[i]); var stat = fs.lstatSync(filename); if (stat.isDirectory()) { var recursed = findHtml(filename); for (var j = 0; j < recursed.length; j++) { recursed[j] = path.join(files[i], recursed[j]).replace(/\\/g, '/');
382
0
32
125 126 127 128 129 130 131 132 133
fs.symlinkSync(file2, link); fs.lchmod(link, mode_async, common.mustCall((err) => { assert.ifError(err); assert.strictEqual(mode_async, fs.lstatSync(link).mode & 0o777); fs.lchmodSync(link, mode_sync); assert.strictEqual(mode_sync, fs.lstatSync(link).mode & 0o777);
16
65
0
99 100 101 102 103 104 105 106 107 108 109
return true; }; fs.lstat(nonexistentFile, common.mustCall(validateError)); assert.throws( () => fs.lstatSync(nonexistentFile), validateError ); }
42
19
0
87 88 89 90 91 92 93 94 95 96
// console.log(childNames) for(let i =0; i<childNames.length; i++){ let childAddress = path.join(src,childNames[i]) let isFile = fs.lstatSync(childAddress).isFile(); if(isFile){ //differeniating file and directory // console.log(childNames[i])
0
0
1
78 79 80 81 82 83 84 85 86 87 88 89 90 91
function treeHelper(dirPath,indent){ // is file or folder let isFile = fs.lstatSync(dirPath).isFile(); if(isFile) { let fileName = path.basename(dirPath)
0
0
1
GitHub: stfnbssl/wizzi
72 73 74 75 76 77 78 79 80 81
} } function getFiles(srcpath, schema) { return fs.readdirSync(srcpath).filter((file) => { return fs.lstatSync(path.join(srcpath, file)).isFile() && verify.endsWith(file, (schema === 'ittf' ? '.ittf' : '.' + schema + '.ittf')); } ) ; }
0
0
2
GitHub: ds-sampaio/ClicouChegouApp
294 295 296 297 298 299 300 301 302 303
files = fs.readdirSync(dir); for (var i = 0, length = files.length; i < length; i++) { var file = path.join(dir, files[i]), stat = fs.lstatSync(file); // lstat so we don't recurse into symlinked directories if (stat.isDirectory()) { if (!deferred) { deferred = true;
0
0
1
15 16 17 18 19 20 21 22 23 24 25
function* walkDirectory(directory, filter) { // Generator for recursively walk a directory. for (const filePath of fs.readdirSync(directory)) { const currentPath = path.join(directory, filePath); const stat = fs.lstatSync(currentPath); if (stat.isFile()) { if (!filter || filter(currentPath)) { yield currentPath; }
0
0
1
+ 2 other calls in file
GitHub: nightwatchjs/nightwatch
391 392 393 394 395 396 397 398 399 400
if (path.isAbsolute(resource)) { sourcePath = path.dirname(resource); resource = path.basename(resource); } const isFolder = fs.lstatSync(path.join(sourcePath, resource)).isDirectory(); if (isFolder) { const pathFolder = path.join(sourcePath, resource); const ns = namespace.slice(0); ns.push(resource);
0
0
262
GitHub: YourKingMax/BOT
25 26 27 28 29 30 31 32 33 34
is_busy = true delete require.cache[file_path] try { require(file_path) mtimeMs = lstatSync(file_path).mtimeMs is_busy = false module.exports.load(require("../../events/ready").bot) } catch (exception) { console.log(`[${file_path.split(sep).pop()} ERRORED | RELOADING IN 5 SECONDS]: ${exception}`)
0
0
1
+ 5 other calls in file
fs.readFileSync is the most popular function in fs (2736 examples)