1 | const { readDir } = require('..')
|
2 | const path = require('path')
|
3 |
|
4 | const dirPath = path.join(__dirname, 'directory');
|
5 |
|
6 | (async () => {
|
7 | const res = await readDir(dirPath)
|
8 | console.log(res)
|
9 | // { 'fileA.txt': 'fileA\n',
|
10 | // 'fileB.txt': 'fileB\n',
|
11 | // 'fileC.txt': 'fileC\n' }
|
12 | })();
|
13 |
|
14 | (async () => {
|
15 | const res = await readDir(dirPath, true)
|
16 | console.log(res)
|
17 | // { 'fileA.txt': 'fileA\n',
|
18 | // 'fileB.txt': 'fileB\n',
|
19 | // 'fileC.txt': 'fileC\n',
|
20 | // subdirectory:
|
21 | // { 'subdirFileA.txt': 'subdirFileA\n',
|
22 | // 'subdirFileB.txt': 'subdirFileB\n' } }
|
23 | })()
|