From fec9c27c3ccc83e2304b9d5a8e8a8329635ce2d3 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 27 Jun 2018 20:31:30 +0800 Subject: [PATCH] Add isSymbolicLink. --- README.md | 2 ++ index.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73509e9..dd54ada 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ readdir('/').then((files) => { // mode: { // number: 16877, // string: 'drwxr-xr-x', + // isSymbolicLink: true, // owner: { read: true, write: true, execute: true }, // group: { read: true, write: false, execute: true }, // others: { read: true, write: false, execute: true } @@ -69,6 +70,7 @@ getStat('/var').then((Stats) => { // mode: { // number: 16877, // string: 'drwxr-xr-x', + // isSymbolicLink: true, // owner: { read: true, write: true, execute: true }, // group: { read: true, write: false, execute: true }, // others: { read: true, write: false, execute: true } diff --git a/index.js b/index.js index f874250..5c3fb1e 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const Mode = require('stat-mode'); exports.getStat = async (currentPath, names) => { if (!names) names = await this.uidToName(); return new Promise((resolve, reject) => { - fs.stat(currentPath, (err, stat) => { + fs.lstat(currentPath, (err, stat) => { if (err) reject(err); else { const mode = new Mode(stat); @@ -15,6 +15,7 @@ exports.getStat = async (currentPath, names) => { } stat.mode = { number: stat.mode, + isSymbolicLink: mode.isSymbolicLink(), string: mode.toString(), owner: { ...mode.owner }, group: { ...mode.group },