.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @nodelib / fs.stat / out / providers / stat.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 function sync(path, options) {
4     const lstat = options.fs.lstatSync(path);
5     if (!isFollowedSymlink(lstat, options)) {
6         return lstat;
7     }
8     try {
9         const stat = options.fs.statSync(path);
10         stat.isSymbolicLink = () => true;
11         return stat;
12     }
13     catch (err) {
14         if (!options.throwErrorOnBrokenSymlinks) {
15             return lstat;
16         }
17         throw err;
18     }
19 }
20 exports.sync = sync;
21 function async(path, options, callback) {
22     options.fs.lstat(path, (err0, lstat) => {
23         if (err0) {
24             return callback(err0, undefined);
25         }
26         if (!isFollowedSymlink(lstat, options)) {
27             return callback(null, lstat);
28         }
29         options.fs.stat(path, (err1, stat) => {
30             if (err1) {
31                 return options.throwErrorOnBrokenSymlinks ? callback(err1) : callback(null, lstat);
32             }
33             stat.isSymbolicLink = () => true;
34             callback(null, stat);
35         });
36     });
37 }
38 exports.async = async;
39 /**
40  * Returns `true` for followed symlink.
41  */
42 function isFollowedSymlink(stat, options) {
43     return stat.isSymbolicLink() && options.followSymlinks;
44 }
45 exports.isFollowedSymlink = isFollowedSymlink;