We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b21dd3 commit dfc6f87Copy full SHA for dfc6f87
directory-iterator-async.js
@@ -0,0 +1,28 @@
1
+const fs = require("fs");
2
+const path = require("path");
3
+
4
+const isFile = file => {
5
+ const stats = fs.lstatSync(file);
6
+ return stats.isFile();
7
+};
8
9
+const getFileName = file => {
10
+ const fileParts = file.split("/");
11
+ return fileParts[fileParts.length - 1];
12
13
14
+const crawl = (file, indentation) => {
15
+ console.log(indentation + getFileName(file));
16
17
+ if (isFile(file)) {
18
+ // collect only files
19
+ } else {
20
+ const files = fs.readdirSync(file);
21
+ files.forEach(subfile => {
22
+ crawl(file + "/" + subfile, indentation + "\t");
23
+ });
24
+ }
25
26
27
+const startingDirectory = "PATH_TO_YOUR_DIRECTORY";
28
+crawl(startingDirectory, 0);
0 commit comments