1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 |
|
4 |
|
5 | module.exports = function (fullUrl) {
|
6 |
|
7 | let files, content = fullUrl;
|
8 | try {
|
9 | files = fs.readdirSync(fullUrl);
|
10 | } catch (e) {
|
11 | content = path.resolve(fullUrl, '../');
|
12 | files = fs.readdirSync(content);
|
13 | }
|
14 |
|
15 | let list = [];
|
16 |
|
17 | for (let i in files) {
|
18 | let isFolder = fs.lstatSync(path.join(content, files[i])).isDirectory();
|
19 |
|
20 |
|
21 | list.push({
|
22 |
|
23 |
|
24 | type: isFolder ? "folder" : "file",
|
25 |
|
26 |
|
27 | url: "./" + files[i] + (isFolder ? "/" : "")
|
28 |
|
29 | });
|
30 |
|
31 | }
|
32 |
|
33 | return list;
|
34 | }; |
\ | No newline at end of file |