Utils class

Common utility functions shared by all tasks and commands

Constructors

Utils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

isInDocker bool
Indicates whether or not this process is running in our docker image
no setter
relativePathRoots Map<KnownPaths, String>
A map of expected KnownPaths relative to a workspace.
final

Static Methods

chmod(String perms, String filePath, [String? workingDir]) bool
Runs a chmod command against the filePath in the workingDir using the provided perms
deleteIfExists(String entityPath) bool
Deletes a FileSystemEntity by entityPath, only if it exists. If entityPath is a directory, it is deleted recursively. Returns true if the entityPath doesn't exist or was deleted, otherwise false.
dockerImageExists(String name) bool
Indicates whether or not a docker image exists by name
findFiles({String? subPath, String? rootDir, RegExp? matcher}) Stream<File>
An async Stream of File instances found responsive to the matcher within the rootDir/subPath location on the file system. THe rootDir will default to Directory.current if not provided
getCPUArch() CpuArch
Checks the OS-reported CPU architecture and returns the appropriate internal CpuArch value.
getFinalDir(String dirPath) String
Returns the result of path.normalize, as an absolute path from Directory.current.
getGitHash([String? dirPath]) String?
Gets the git hash from dirPath, if it's a repo, otherwise null.
getIaCValue(String targetDir, String key) String?
Gets the value of key from the iac.json file in the targetDir.
getPubSpecValue(String targetDir, String key) String?
Gets the value of key from the pubspec.yaml file in the targetDir.
getTempPath([String prefix = 'endaft']) String
Creates a temporary Directory under the system temporary directory and returns the absolute path to it.
handleProcessResult(ProcessResult result, Logger logger, [String indent = '', ProcessFinalizer? finalizer, String message = '']) bool
Handles the child process results and outputs
installCommand(String command) bool
Checks if command is executable on this system.
isCommand(String command) bool
Checks if command is executable on this system.
pathFromRoot(KnownPaths type, [String? rootDir, bool create = true]) String
Gets a path from within the rootDir for the specified type, this will optionally create the directory if it doesn't already exist.
readFile<T>({required File file, required FileParser<T> parser}) → T
Attempts to read a File from the specified filePath, and parse it with the specified parser. Common FileParser implementations are available from FileParsers. If the file doesn't exist, throws a FileSystemException
readFilePath<T>({required String filePath, required FileParser<T> parser}) → T
Attempts to read a File from the specified filePath, and parse it with the specified parser. Common FileParser implementations are available from FileParsers. If the file doesn't exist, throws a FileSystemException
readSchemaFile(String filePath, [FileCreator? creator]) → JsonSchema
Reads the file at filePath as a JsonSchema
toolPath(String command) String?
Get the full path to command on this system, or null if the command is not available.