asajs
Version:
Make your Minecraft JsonUI with ScriptingAPI
71 lines (70 loc) • 2.66 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var SearchFiles_exports = {};
__export(SearchFiles_exports, {
SearchFiles: () => SearchFiles
});
module.exports = __toCommonJS(SearchFiles_exports);
var import_Class = require("../../components/Class");
var import_fs = __toESM(require("fs"));
function searchForEachFileRecursion(path, callback, $1 = "", $2 = "", $3 = "") {
var _a;
if (import_fs.default.statSync(path).isDirectory())
for (const file of import_fs.default.readdirSync(path))
searchForEachFileRecursion(
"".concat(path, "/").concat(file),
callback,
file,
"".concat($2, "/").concat(file),
(_a = $2.match(/(?<=\/)\w+$/)) == null ? void 0 : _a[0]
);
else
callback({
file: $1,
folder: $3 === "" ? void 0 : $3,
path: $2.slice(1)
});
}
class SearchFiles extends import_Class.Class {
static array(folderPath, prefix) {
const paths = [];
SearchFiles.forEach(
folderPath,
(value) => paths.push("".concat(prefix ? "".concat(prefix, "/") : "").concat(value.path))
);
return paths;
}
static forEach(folderPath, callback) {
searchForEachFileRecursion(folderPath, callback);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SearchFiles
});