Class: Directory
A directory.
Extends
BaseClient
Constructors
Constructor
new Directory(
ctx
?,_id
?,_digest
?,_export
?,_name
?,_sync
?):Directory
Constructor is used for internal usage only, do not create object from it.
Parameters
ctx?
Context
_id?
_digest?
string
_export?
string
_name?
string
_sync?
Returns
Directory
Overrides
BaseClient.constructor
Methods
asGit()
asGit():
GitRepository
Converts this directory to a local git repository
Returns
asModule()
asModule(
opts
?):Module_
Load the directory as a Dagger module source
Parameters
opts?
Returns
asModuleSource()
asModuleSource(
opts
?):ModuleSource
Load the directory as a Dagger module source
Parameters
opts?
Returns
diff()
diff(
other
):Directory
Return the difference between this directory and an another directory. The difference is encoded as a directory.
Parameters
other
Directory
The directory to compare against
Returns
Directory
digest()
digest():
Promise
<string
>
Return the directory's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
Returns
Promise
<string
>
directory()
directory(
path
):Directory
Retrieves a directory at the given path.
Parameters
path
string
Location of the directory to retrieve. Example: "/src"
Returns
Directory
dockerBuild()
dockerBuild(
opts
?):Container
Use Dockerfile compatibility to build a container from this directory. Only use this function for Dockerfile compatibility. Otherwise use the native Container type directly, it is feature-complete and supports all Dockerfile features.
Parameters
opts?
Returns
entries()
entries(
opts
?):Promise
<string
[]>
Returns a list of files and directories at the given path.
Parameters
opts?
Returns
Promise
<string
[]>
export()
export(
path
,opts
?):Promise
<string
>
Writes the contents of the directory to a path on the host.
Parameters
path
string
Location of the copied directory (e.g., "logs/").
opts?
Returns
Promise
<string
>
file()
file(
path
):File
Retrieve a file at the given path.
Parameters
path
string
Location of the file to retrieve (e.g., "README.md").
Returns
filter()
filter(
opts
?):Directory
Return a snapshot with some paths included or excluded
Parameters
opts?
Returns
Directory
glob()
glob(
pattern
):Promise
<string
[]>
Returns a list of files and directories that matche the given pattern.
Parameters
pattern
string
Pattern to match (e.g., "*.md").
Returns
Promise
<string
[]>
id()
id():
Promise
<DirectoryID
>
A unique identifier for this Directory.
Returns
Promise
<DirectoryID
>
name()
name():
Promise
<string
>
Returns the name of the directory.
Returns
Promise
<string
>
sync()
sync():
Promise
<Directory
>
Force evaluation in the engine.
Returns
Promise
<Directory
>
terminal()
terminal(
opts
?):Directory
Opens an interactive terminal in new container with this directory mounted inside.
Parameters
opts?
Returns
Directory
with()
with(
arg
):Directory
Call the provided function with current Directory.
This is useful for reusability and readability by not breaking the calling chain.
Parameters
arg
(param
) => Directory
Returns
Directory
withDirectory()
withDirectory(
path
,directory
,opts
?):Directory
Return a snapshot with a directory added
Parameters
path
string
Location of the written directory (e.g., "/src/").
directory
Directory
Identifier of the directory to copy.
opts?
Returns
Directory
withFile()
withFile(
path
,source
,opts
?):Directory
Retrieves this directory plus the contents of the given file copied to the given path.
Parameters
path
string
Location of the copied file (e.g., "/file.txt").
source
Identifier of the file to copy.
opts?
Returns
Directory
withFiles()
withFiles(
path
,sources
,opts
?):Directory
Retrieves this directory plus the contents of the given files copied to the given path.
Parameters
path
string
Location where copied files should be placed (e.g., "/src").
sources
File
[]
Identifiers of the files to copy.
opts?
Returns
Directory
withNewDirectory()
withNewDirectory(
path
,opts
?):Directory
Retrieves this directory plus a new directory created at the given path.
Parameters
path
string
Location of the directory created (e.g., "/logs").
opts?
Returns
Directory
withNewFile()
withNewFile(
path
,contents
,opts
?):Directory
Return a snapshot with a new file added
Parameters
path
string
Path of the new file. Example: "foo/bar.txt"
contents
string
Contents of the new file. Example: "Hello world!"
opts?
Returns
Directory
withoutDirectory()
withoutDirectory(
path
):Directory
Return a snapshot with a subdirectory removed
Parameters
path
string
Path of the subdirectory to remove. Example: ".github/workflows"
Returns
Directory
withoutFile()
withoutFile(
path
):Directory
Return a snapshot with a file removed
Parameters
path
string
Path of the file to remove (e.g., "/file.txt").
Returns
Directory
withoutFiles()
withoutFiles(
paths
):Directory
Return a snapshot with files removed
Parameters
paths
string
[]
Paths of the files to remove (e.g., ["/file.txt"]).
Returns
Directory
withTimestamps()
withTimestamps(
timestamp
):Directory
Retrieves this directory with all file/dir timestamps set to the given time.
Parameters
timestamp
number
Timestamp to set dir/files in.
Formatted in seconds following Unix epoch (e.g., 1672531199).
Returns
Directory