forked from AlexzanderFlores/WOKCommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-all-files.js
32 lines (32 loc) · 1.22 KB
/
get-all-files.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var fs_1 = __importDefault(require("fs"));
var getAllFiles = function (dir) {
var files = fs_1.default.readdirSync(dir, {
withFileTypes: true,
});
var jsFiles = [];
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var file = files_1[_i];
if (file.isDirectory()) {
jsFiles = __spreadArrays(jsFiles, getAllFiles(dir + "/" + file.name));
}
else if (file.name.endsWith('.js')) {
var fileName = file.name.replace(/\\/g, '/').split('/');
fileName = fileName[fileName.length - 1];
fileName = fileName.split('.')[0].toLowerCase();
jsFiles.push([dir + "/" + file.name, fileName]);
}
}
return jsFiles;
};
module.exports = getAllFiles;