-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathtest-stat-identity.mjs
More file actions
34 lines (29 loc) · 788 Bytes
/
test-stat-identity.mjs
File metadata and controls
34 lines (29 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// test-stat-identity.mjs
import { statSync, rmSync } from 'fs';
import { mkdirSync, symlinkSync } from 'fs';
import { join, resolve } from 'path';
const tmp = resolve('tmp_stat_test');
try {
rmSync(tmp, { recursive: true, force: true });
} catch {}
try {
mkdirSync(tmp);
} catch {}
const dir = join(tmp, 'real_dir');
try {
mkdirSync(dir);
} catch {}
const link1 = join(tmp, 'link1');
// Link points to 'real_dir' which is in the same folder as 'link1'
try {
symlinkSync('real_dir', link1);
} catch {}
try {
const s1 = statSync(dir);
const s2 = statSync(link1);
console.log(`Real: dev=${s1.dev}, ino=${s1.ino}`);
console.log(`Link: dev=${s2.dev}, ino=${s2.ino}`);
console.log(`Match? ${s1.dev === s2.dev && s1.ino === s2.ino}`);
} catch (e) {
console.error(e);
}