env

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package env provides NodeExecutionEnv, the host-OS filesystem and shell implementation of the harness execution environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeExecutionEnv

type NodeExecutionEnv struct {
	// contains filtered or unexported fields
}

NodeExecutionEnv is the host-OS execution environment: filesystem access and bash command execution for the harness. Its name mirrors the upstream Node.js implementation.

func NewNodeExecutionEnv

func NewNodeExecutionEnv(options NodeExecutionEnvOptions) *NodeExecutionEnv

NewNodeExecutionEnv constructs an environment rooted at options.Cwd.

func (*NodeExecutionEnv) AbsolutePath

func (env *NodeExecutionEnv) AbsolutePath(_ context.Context, path string) (string, error)

AbsolutePath resolves path without requiring it to exist.

func (*NodeExecutionEnv) AppendFile

func (env *NodeExecutionEnv) AppendFile(ctx context.Context, path string, content []byte) error

AppendFile creates or appends to path, creating parent directories.

func (*NodeExecutionEnv) CanonicalPath

func (env *NodeExecutionEnv) CanonicalPath(ctx context.Context, path string) (string, error)

CanonicalPath resolves every symlink in an existing path.

func (*NodeExecutionEnv) Cleanup

func (env *NodeExecutionEnv) Cleanup(context.Context)

Cleanup terminates every active command's process tree.

func (*NodeExecutionEnv) CreateDir

func (env *NodeExecutionEnv) CreateDir(ctx context.Context, path string, options *harness.CreateDirOptions) error

CreateDir creates a directory; Recursive defaults to true.

func (*NodeExecutionEnv) CreateTempDir

func (env *NodeExecutionEnv) CreateTempDir(ctx context.Context, prefix *string) (string, error)

CreateTempDir creates a directory named prefix plus six random characters under the OS temp directory; prefix defaults to "tmp-".

func (*NodeExecutionEnv) CreateTempFile

func (env *NodeExecutionEnv) CreateTempFile(ctx context.Context, options *harness.CreateTempFileOptions) (string, error)

CreateTempFile creates an empty file named prefix + UUID + suffix inside a fresh temporary directory.

func (*NodeExecutionEnv) Cwd

func (env *NodeExecutionEnv) Cwd() string

Cwd is the directory relative paths resolve against.

func (*NodeExecutionEnv) Exec

Exec runs command through bash in the environment cwd (or options.Cwd). The combined stdout/stderr view is bounded and published through options.OnUpdate; a non-zero exit is a successful result. Cancellation of ctx, the timeout, a failing OnUpdate, and a failed requested spill each kill the process tree and fail the call.

func (*NodeExecutionEnv) Exists

func (env *NodeExecutionEnv) Exists(ctx context.Context, path string) (bool, error)

Exists reports false for missing paths and other failures as errors.

func (*NodeExecutionEnv) FileInfo

func (env *NodeExecutionEnv) FileInfo(ctx context.Context, path string) (harness.FileInfo, error)

FileInfo returns metadata without following symlinks.

func (*NodeExecutionEnv) JoinPath

func (env *NodeExecutionEnv) JoinPath(_ context.Context, parts []string) (string, error)

JoinPath joins and normalizes path segments like Node's path.join.

func (*NodeExecutionEnv) ListDir

func (env *NodeExecutionEnv) ListDir(ctx context.Context, path string) ([]harness.FileInfo, error)

ListDir lists direct children in directory order without following symlinks; unsupported file types are omitted.

func (*NodeExecutionEnv) OpenTextLineReader

func (env *NodeExecutionEnv) OpenTextLineReader(ctx context.Context, path string) (harness.TextLineReader, error)

OpenTextLineReader opens path for pull-based line reading.

func (*NodeExecutionEnv) ReadBinaryFile

func (env *NodeExecutionEnv) ReadBinaryFile(ctx context.Context, path string) ([]byte, error)

ReadBinaryFile reads path.

func (*NodeExecutionEnv) ReadTextFile

func (env *NodeExecutionEnv) ReadTextFile(ctx context.Context, path string) (string, error)

ReadTextFile reads path as UTF-8, replacing invalid sequences.

func (*NodeExecutionEnv) ReadTextLines

func (env *NodeExecutionEnv) ReadTextLines(ctx context.Context, path string, options *harness.ReadTextLinesOptions) ([]string, error)

ReadTextLines reads up to options.MaxLines lines; a non-positive limit returns no lines.

func (*NodeExecutionEnv) Remove

func (env *NodeExecutionEnv) Remove(ctx context.Context, path string, options *harness.RemoveOptions) error

Remove deletes a file or directory; a directory requires Recursive and a missing path requires Force.

func (*NodeExecutionEnv) RenameFile

func (env *NodeExecutionEnv) RenameFile(ctx context.Context, sourcePath, destinationPath string) error

RenameFile atomically renames sourcePath over destinationPath.

func (*NodeExecutionEnv) WriteFile

func (env *NodeExecutionEnv) WriteFile(ctx context.Context, path string, content []byte) error

WriteFile creates or overwrites path, creating parent directories.

type NodeExecutionEnvOptions

type NodeExecutionEnvOptions struct {
	Cwd string
	// ShellPath is an explicit bash executable; empty selects the platform
	// default.
	ShellPath string
	// ShellEnv is layered over the inherited process environment for every
	// command.
	ShellEnv map[string]string
}

NodeExecutionEnvOptions configure a NodeExecutionEnv.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL