Skip to main content

Documentation Index

Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt

Use this file to discover all available pages before exploring further.

basename(path) returns the final component of path, stripping any directory prefix.

Signature

basename(path string) string

Example

Extract the filename from a variable holding a full artifact path and use it as the upload target name:
variable "artifact_path" {
  description = "Full path to the build artifact"
  type        = string
}

computed "artifact_name" {
  description = "Filename of the artifact"
  expression  = basename(var.artifact_path)
}

task "publish" {
  description = "Upload the artifact to the release"
  commands = [
    "gh release upload ${var.version} ${var.artifact_path}#${computed.artifact_name}",
  ]
}
/workspace/dist/myapp-1.2.0-linux-amd64.tar.gz becomes myapp-1.2.0-linux-amd64.tar.gz.

Notes

  • basename does not check whether the path exists.
  • Trailing slashes in path are stripped before extracting the base name.
  • To get the directory component, use dirname.