(depth, files, folders, dirname, createSymLinks)
| 26 | } |
| 27 | |
| 28 | function makeNonEmptyDirectory(depth, files, folders, dirname, createSymLinks) { |
| 29 | fs.mkdirSync(dirname, common.mustNotMutateObjectDeep({ recursive: true })); |
| 30 | fs.writeFileSync(path.join(dirname, 'text.txt'), 'hello', 'utf8'); |
| 31 | |
| 32 | const options = common.mustNotMutateObjectDeep({ flag: 'wx' }); |
| 33 | |
| 34 | for (let f = files; f > 0; f--) { |
| 35 | fs.writeFileSync(path.join(dirname, `f-${depth}-${f}`), '', options); |
| 36 | } |
| 37 | |
| 38 | if (createSymLinks) { |
| 39 | // Valid symlink |
| 40 | fs.symlinkSync( |
| 41 | `f-${depth}-1`, |
| 42 | path.join(dirname, `link-${depth}-good`), |
| 43 | 'file' |
| 44 | ); |
| 45 | |
| 46 | // Invalid symlink |
| 47 | fs.symlinkSync( |
| 48 | 'does-not-exist', |
| 49 | path.join(dirname, `link-${depth}-bad`), |
| 50 | 'file' |
| 51 | ); |
| 52 | |
| 53 | // Symlinks that form a loop |
| 54 | [['a', 'b'], ['b', 'a']].forEach(([x, y]) => { |
| 55 | fs.symlinkSync( |
| 56 | `link-${depth}-loop-${x}`, |
| 57 | path.join(dirname, `link-${depth}-loop-${y}`), |
| 58 | 'file' |
| 59 | ); |
| 60 | }); |
| 61 | } |
| 62 | |
| 63 | // File with a name that looks like a glob |
| 64 | fs.writeFileSync(path.join(dirname, '[a-z0-9].txt'), '', options); |
| 65 | |
| 66 | depth--; |
| 67 | if (depth <= 0) { |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | for (let f = folders; f > 0; f--) { |
| 72 | fs.mkdirSync( |
| 73 | path.join(dirname, `folder-${depth}-${f}`), |
| 74 | { recursive: true } |
| 75 | ); |
| 76 | makeNonEmptyDirectory( |
| 77 | depth, |
| 78 | files, |
| 79 | folders, |
| 80 | path.join(dirname, `d-${depth}-${f}`), |
| 81 | createSymLinks |
| 82 | ); |
| 83 | } |
| 84 | } |
| 85 |
no test coverage detected
searching dependent graphs…