file¶
type file < targetA file target represents a single file or directory in the filesystem. File targets are stored relative to the project root whenever possible, taking into account virtual mounts. They are automatically resolving to absolute paths when required.
fun file(Path: string, BuildFn?: any): fileReturns a new file target. If
Pathdoes not begin with /, it is considered relative to the current context path. IfPathis specified as an absolute path but lies inside the project directory, it is converted into a relative path.meth (File: file) % (Extension: string): fileReturns a new file target by replacing the extension of
FilewithExtension.meth (Target: file) - (Source: file): string | nilReturns the relative path of
TargetinSource, ornilifTargetis not contained inSource.meth (Directory: file) / (Name: string): fileReturns a new file target at
Directory/Name.meth (Target: file):absolute: target | nilReturns
Targetif is has an absolute path, otherwise returnsnil.meth (Target: file):basename: stringReturns the filename component of
Target.meth (Directory: file):chdir: fileChanges the current directory to
Directory. ReturnsDirectory.meth (Source: file):copy(Dest: file): nilCopies the contents of
SourcetoDest.meth (Target: file):dir: fileReturns the directory containing
Target.meth (Target: file):dirname: stringReturns the directory containing
Targetas a string. Virtual mounts are not applied to the result (unlikeTarget:dir).meth (Target: file):exists: file | nilReturns
Targetif the file or directory exists or has a build function defined, otherwise returnsnil.meth (Target: file):extension: stringReturns the file extension of
Target.meth (Directory: file):ls(Pattern?: string|regex, Recursive?: method, Filter?: function, ...): list[target]Returns a list of the contents of
Directory. Passing:Rresults in a recursive list.meth (Target: file):map(Source: file, Dest: file): file | errorReturns the relative path of
TargetinSourceapplied toDest, or an error ifTargetis not contained inSource.meth (Directory: file):mkdir: fileCreates the all directories in the path of
Directory. ReturnsDirectory.meth (Target: file):open(Mode: string): streamOpens the file at
Targetwith modeMode.meth (Target: file):path: stringReturns the internal (possibly unresolved and relative to project root) path of
Target.meth (Target: file):relative: target | nilReturns
Targetif is has a relative path, otherwise returnsnil.meth (Source: file):rename(Arg₂: file): DestRenames the file at
SourcetoDest.meth (Target: file):rmdir: fileRemoves
Targetrecursively. ReturnsDirectory.meth (Target: file):unlink: TargetUnlinks the file at
Target.