magus v0.4.2 is out. See what's new
¶ View generated markdown
2 min read

path

Pure path-string math: abs, rel, clean, is_abs, expand_user, and glob matching.

Naming convention: import the module under its bare name (import "path"), reach members with a backslash, and call methods in camelCase: path\someMethod.

Methods

abs

Return the absolute form of path, resolved against the current directory and lexically cleaned.

Signature: path\abs(path) -> string - source

Parameter Type Optional Description
path string

Returns: string

rel

Return a relative path from base to target; errors if no relative path exists.

Signature: path\rel(base, target) -> string - source

Parameter Type Optional Description
base string
target string

Returns: string

clean

Return the shortest lexically-equivalent path (resolves . and .., collapses separators).

Signature: path\clean(path) -> string - source

Parameter Type Optional Description
path string

Returns: string

isAbs

Report whether path is absolute.

Signature: path\isAbs(path) -> bool - source

Parameter Type Optional Description
path string

Returns: bool

matches

Report whether path matches a doublestar glob (** crosses directory separators, * does not). Purely lexical: unlike fs.glob it touches no filesystem, so it is what filters a list already in hand - the changed files from vcs.changed_files, the entries from archive.list - against the same pattern syntax a target's sources use. Raises on a malformed pattern rather than reporting no match, so a typo is not read as "nothing changed".

Signature: path\matches(pattern, path) -> bool - source

Parameter Type Optional Description
pattern string
path string

Returns: bool

matchesAny

Report whether path matches ANY of the patterns; an empty pattern list is false. The common shape of a declared source or ignore set, which is a list rather than one glob.

Signature: path\matchesAny(patterns, path) -> bool - source

Parameter Type Optional Description
patterns []string
path string

Returns: bool

expandUser

Expand a leading ~ (or ~/...) to the current user's home directory; other paths are returned unchanged.

Signature: path\expandUser(path) -> string - source

Parameter Type Optional Description
path string

Returns: string

generatedreference/buzz/pathmodulestdlibmagusfile
Last updated (4f8cc295)
Earlier changes on this page (4)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.