Skip to content

Commit 1547cc2

Browse files
committed
just listdir
1 parent 0e99e9e commit 1547cc2

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

index.js

+3-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,7 @@
1-
var _getAllFilesFromFolder = function (dir) {
2-
var filesystem = require("fs");
3-
var results = [];
4-
5-
filesystem.readdirSync(dir).forEach(function (file) {
6-
file = dir + "/" + file;
7-
var stat = filesystem.statSync(file);
8-
9-
if (stat && stat.isDirectory()) {
10-
results = results.concat(_getAllFilesFromFolder(file));
11-
} else results.push(file);
12-
});
13-
14-
return results;
15-
};
1+
const fs = require("fs");
162

173
module.exports.handler = async (event) => {
184
const dir = event.dir || "/";
19-
return {
20-
statusCode: 200,
21-
body: JSON.stringify(
22-
{
23-
message: JSON.stringify(_getAllFilesFromFolder(dir)),
24-
input: event,
25-
},
26-
null,
27-
2
28-
),
29-
};
5+
console.log("listing files in dir: ", dir);
6+
return fs.readdirSync(dir).join("\n");
307
};

0 commit comments

Comments
 (0)