|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +// Refs: https://github.com/nodejs/node/issues/52663 |
| 4 | +const common = require('../common'); |
| 5 | +const assert = require('node:assert'); |
| 6 | +const fs = require('node:fs'); |
| 7 | +const path = require('node:path'); |
| 8 | + |
| 9 | +if (!common.canCreateSymLink()) |
| 10 | + common.skip('insufficient privileges'); |
| 11 | + |
| 12 | +const tmpdir = require('../common/tmpdir'); |
| 13 | +const readdirDir = tmpdir.path; |
| 14 | +// clean up the tmpdir |
| 15 | +tmpdir.refresh(); |
| 16 | + |
| 17 | +// a/1, a/2 |
| 18 | +const a = path.join(readdirDir, 'a'); |
| 19 | +fs.mkdirSync(a); |
| 20 | +fs.writeFileSync(path.join(a, '1'), 'irrelevant'); |
| 21 | +fs.writeFileSync(path.join(a, '2'), 'irrelevant'); |
| 22 | + |
| 23 | +// b/1 |
| 24 | +const b = path.join(readdirDir, 'b'); |
| 25 | +fs.mkdirSync(b); |
| 26 | +fs.writeFileSync(path.join(b, '1'), 'irrelevant'); |
| 27 | + |
| 28 | +// b/c -> a |
| 29 | +const c = path.join(readdirDir, 'b', 'c'); |
| 30 | +fs.symlinkSync(a, c, 'dir'); |
| 31 | + |
| 32 | +// Just check that the number of entries are the same |
| 33 | +assert.strictEqual( |
| 34 | + fs.readdirSync(b, { recursive: true, withFileTypes: true }).length, |
| 35 | + fs.readdirSync(b, { recursive: true, withFileTypes: false }).length |
| 36 | +); |
0 commit comments