Skip to main content

resolve_theme_path

Function resolve_theme_path 

Source
pub fn resolve_theme_path(
    theme: &str,
    search_root: &Path,
) -> Result<PathBuf, TokenError>
Expand description

Resolve a --theme value to a file path on disk.

Resolution order:

  1. If theme is a path to an existing file, use it directly.
  2. Otherwise, treat it as an npm package name and walk up from search_root looking for node_modules/<pkg>/tokens.json:
    • @scope/pkg โ†’ node_modules/@scope/pkg/tokens.json
    • @scope/pkg/custom.json โ†’ node_modules/@scope/pkg/custom.json
    • pkg โ†’ node_modules/pkg/tokens.json

ยงErrors

Returns TokenError::Schema if the theme cannot be resolved.