Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs #162

Open
magicdawn opened this issue May 4, 2023 · 1 comment
Open

fs #162

magicdawn opened this issue May 4, 2023 · 1 comment

Comments

@magicdawn
Copy link
Owner

No description provided.

@magicdawn
Copy link
Owner Author

magicdawn commented May 4, 2023

symlink

resolve symlink

realpath

Asynchronously computes the canonical pathname by resolving ., .., and symbolic links.

A canonical pathname is not necessarily unique. Hard links and bind mounts can expose a file system entity through many pathnames.

支持多层 symlink, 但是 symlink 的 target 需要存在, 否则 ENOENT

readlink

读取 link 的字符串信息, 需要 manual resolve

create symlink

术语比较混乱, src, dest, from, target

dir 比较特殊

使用 https://www.npmjs.com/package/symlink-dir

symlink('/dir/a', '/dir/b');
// /dir/b -> /dir/a

签名 symlinkDir(src, dest, opts?), symlink dest 指向 src. (啊!

fs.symlink

import { symlink } from 'node:fs';
symlink('./mew', './mewtwo', callback); 
$ tree .
.
├── mew
└── mewtwo -> ./mew 

ln -s ./mew ./mewtwo

结论

都是 (existing, newSymlinkFile)

$ tree .
.
├── existing
└── newSymlinkFile -> ./existing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant