UNPKG

@sprucelabs/spruce-skill-utils

Version:

Loosely coupled classes and functions to make skill development faster! 🏎

32 lines (31 loc) 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const globby_1 = __importDefault(require("@sprucelabs/globby")); const addonUtil = { async import(options, ...path) { const results = await (0, globby_1.default)(path_1.default.join(...path, '**', '*.addon.[t|j]s')); const all = results.map((path) => { const result = require(path); if (typeof result?.default === 'function') { return result.default(options); } }); await Promise.all(all); return results.length; }, importSync(options, ...path) { const results = globby_1.default.sync(path_1.default.join(...path, '**', '*.addon.[t|j]s')); results.forEach((path) => { const result = require(path); if (typeof result?.default === 'function') { result.default(options); } }); return results.length; }, }; exports.default = addonUtil;