os version:
➜ showlink sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B35a
before exec the script:
➜ showlink tree --inodes .
.
└── [9628588] test
├── [9628740] link.js
└── [9628707] src
2 directories, 1 file
nodejs script :
const fs = require('fs')
const path = require('path')
const src = path.resolve(__dirname, './src')
//i try to the dist at the same dir with src, but failed
const dist = path.join(__dirname, '../dist')
fs.link(src, dist, (err) => console.log(err))
after:
➜ showlink tree --inodes .
.
├── [9628707] dist
└── [9628588] test
├── [9628740] link.js
└── [9628707] src
3 directories, 1 file
add some file
➜ showlink touch test/src/demo{1..3}
now:
➜ showlink tree --inodes .
.
├── [9628707] dist
│ ├── [9629200] demo1
│ ├── [9629201] demo2
│ └── [9629202] demo3
└── [9628588] test
├── [9628740] link.js
└── [9628707] src
├── [9629200] demo1
├── [9629201] demo2
└── [9629202] demo3
3 directories, 7 files
when i search google 'hard-link' ,all answer show me that: the dir can't make a hard link . but ... node.js create the dir's hard-link (the number in Brackets is i-node number). what happened? Thanks