UNPKG

zephyr-agent

Version:
31 lines (30 loc) • 1.18 kB
import "node:module"; const DEFAULT_MANIFEST_FILENAME = 'mf-manifest.json'; const JSON_EXT = '.json'; function resolveMfManifestPath(manifest) { if (false === manifest) return; const filePath = 'object' == typeof manifest ? manifest?.filePath ?? '' : ''; const fileName = 'object' == typeof manifest ? manifest?.fileName ?? '' : ''; const resolvedFileName = fileName ? ensureJsonExt(fileName) : DEFAULT_MANIFEST_FILENAME; return simpleJoin(filePath, resolvedFileName); } function ensureJsonExt(name) { return name.endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}`; } function simpleJoin(dir, name) { if (!dir) return name; const normalized = normalizeDir(dir); if (!normalized) return name; return normalized.endsWith('/') ? `${normalized}${name}` : `${normalized}/${name}`; } function normalizeDir(dir) { if ('.' === dir) return ''; if (dir.startsWith('./')) return dir.slice(2); if (dir.startsWith('/')) { const stripped = dir.slice(1); return stripped.endsWith('/') ? stripped.slice(0, -1) : stripped; } return dir; } export { resolveMfManifestPath }; //# sourceMappingURL=resolve-mf-manifest-path.mjs.map