Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/green-mice-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@e2b/python-sdk': patch
'e2b': patch
---

add doublestar pattern when not specified to folder when calling .copy()
10 changes: 9 additions & 1 deletion packages/js-sdk/src/template/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ export async function calculateFilesHash(
stackTrace: string | undefined
): Promise<string> {
const { glob } = await dynamicGlob()
const srcPath = path.join(contextPath, src)
let srcPath = path.join(contextPath, src)
const hash = crypto.createHash('sha256')
const content = `COPY ${src} ${dest}`

hash.update(content)

// check if the srcPath is a directory appending ** if no pattern is used
if (
!src.includes('*') &&
fs.statSync(srcPath, { throwIfNoEntry: false })?.isDirectory()
) {
srcPath = path.join(srcPath, '**')
}

const files = await glob(srcPath, {
ignore: ignorePatterns,
withFileTypes: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/python-sdk/e2b/template/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def calculate_files_hash(

hash_obj.update(content.encode())

# check if the src_path is a directory appending ** if no pattern is used
if "*" not in src and os.path.isdir(src_path):
src_path = os.path.join(src_path, "**")

files_glob = glob(src_path, recursive=True)

files = []
Expand Down