UNPKG

@maverick-js/compiler

Version:

Maverick toolchain including the analyzer and compiler.

30 lines (25 loc) 1.12 kB
import { isUndefined, isString } from './chunk-3M33KLBM.js'; import { normalize, resolve } from 'pathe'; // src/analyze/meta/component.ts var TS_NODE = Symbol("NODE"); var resolvePath = (...pathSegments) => normalize(resolve(...pathSegments)); // src/analyze/utils/resolve.ts async function resolveConfigPaths(cwd, config, match = (key) => isString(key) && (key.endsWith("File") || key.endsWith("Dir"))) { const configWithResolvedPaths = { ...config }; const rcwd = cwd.startsWith(".") ? resolvePath(process.cwd(), cwd) : cwd; if (Object.keys(config).includes("cwd")) { configWithResolvedPaths.cwd = rcwd; } Object.keys(config).forEach((key) => { if (!isUndefined(config[key]) && match(key)) { configWithResolvedPaths[key] = resolvePath(rcwd, config[key]); } }); return configWithResolvedPaths; } // src/utils/str.ts function camelToKebabCase(str) { return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); } var escapeQuotes = (str) => str.replace(/^"+|"+$/g, "").replace(/^'+|'+$/g, ""); export { TS_NODE, camelToKebabCase, escapeQuotes, resolveConfigPaths, resolvePath };