Node.js:在使用"fs"遍历目录时检查文件是否为符号链接 [英] Node.js: Check if file is an symbolic link when iterating over directory with 'fs'

查看:170
本文介绍了Node.js:在使用"fs"遍历目录时检查文件是否为符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Supervisor是Node.js的软件包,它监视您的应用目录中的文件是否有修改,并在发生修改时重新加载应用.

Supervisor is a package for Node.js that monitors files in your app directory for modifications and reloads the app when a modification occurs.

此脚本将符号链接解释为常规文件,并注销警告.我想派遣Supervisor,以便可以完全解决此问题或产生更具描述性的警告.

This script interprets symbolic links as regular files and logs out a warning. I would like to fork Supervisor so that either this can be fixed entirely or that a more descriptive warning is produced.

如何使用Node.js的文件系统模块确定给定文件是否真的是符号链接?

How can I use the File System module of Node.js to determine if a given file is really an symbolic link?

推荐答案

您可以使用 fs.lstat ,然后在

You can use fs.lstat and then call statis.isSymbolicLink() on the fs.Stats object that's passed into your lstat callback.

fs.lstat('myfilename', function(err, stats) {
    console.log(stats.isSymbolicLink());
});

这篇关于Node.js:在使用"fs"遍历目录时检查文件是否为符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆