Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

feat(cli): When creating env, make tar in tmp dir to avoid polluting cwd (#190)

Pavel 'Strajk' Dolecekb8c3ec814545
diff --git a/.changeset/polite-ants-cover.md b/.changeset/polite-ants-cover.md
new file mode 100644
index 000000000..a1a8fc2b3
--- /dev/null
+++ b/.changeset/polite-ants-cover.md
@@ -0,0 +1,5 @@
+---
+'@e2b/cli': patch
+---
+
+When creating env, make tar in tmp dir to avoid polluting cwd
diff --git a/packages/cli/package.json b/packages/cli/package.json
index bb0aae2c1..d8a8200b8 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -21,7 +21,8 @@
"scripts": {
"prepublishOnly": "npm run build",
"build": "rm -rf ./dist && tsup --minify",
- "dev": "tsup --watch"
+ "dev": "tsup --watch",
+ "test-e2b": "cd testground/demo-basic && ../../dist/index.js env create"
},
"devDependencies": {
"@types/common-tags": "^1.8.2",
diff --git a/packages/cli/src/commands/env/create.ts b/packages/cli/src/commands/env/create.ts
index d77a9ca8e..7380cd663 100644
--- a/packages/cli/src/commands/env/create.ts
+++ b/packages/cli/src/commands/env/create.ts
@@ -17,6 +17,8 @@ import {
asLocalRelative,
} from 'src/utils/format'
import * as yup from 'yup'
+import * as os from 'os'
+import path from 'path'
export const createCommand = new commander.Command('create')
.description(`Create new environment and ${asLocal(configName)} config`)
@@ -78,8 +80,8 @@ export const createCommand = new commander.Command('create')
console.log(`• ${filePath.rootPath}`)
})
- // TODO: Create in temp dir
- const tarPath = 'env.tar.gz'
+ const tempDir = os.tmpdir()
+ const tarPath = path.join(tempDir, 'env.tar.gz')
await packToTar(
root,