Skip to content

Commit 28de02a

Browse files
lino-levanmxcl
authored andcommitted
feat: TEA_MAGIC=prompt
1 parent 4b2c03a commit 28de02a

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/hooks/useConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface Env {
2020
TEA_DIR?: string
2121
TEA_FILES?: string
2222
TEA_FORK_BOMB_PROTECTOR?: string
23+
TEA_MAGIC?: string
2324
TEA_PANTRY_PATH?: string
2425
TEA_PKGS?: string
2526
TEA_PREFIX?: string

src/init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function collectEnv(): Env {
5757
TEA_DIR: Deno.env.get("TEA_DIR"),
5858
TEA_FILES: Deno.env.get("TEA_FILES"),
5959
TEA_FORK_BOMB_PROTECTOR: Deno.env.get("TEA_FORK_BOMB_PROTECTOR"),
60+
TEA_MAGIC: Deno.env.get("TEA_MAGIC"),
6061
TEA_PANTRY_PATH: Deno.env.get("TEA_PANTRY_PATH"),
6162
TEA_PKGS: Deno.env.get("TEA_PKGS"),
6263
TEA_PREFIX: Deno.env.get("TEA_PREFIX"),

src/prefab/install.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,27 @@ export default async function install(pkg: Package, logger?: Logger): Promise<In
1212

1313
const cellar = useCellar()
1414
const tea_prefix = usePrefix()
15-
const { isCI, dryrun, json } = useConfig()
15+
const { isCI, dryrun, json, env } = useConfig()
1616
const compression = get_compression(isCI)
1717
const stowage = StowageNativeBottle({ pkg: { project, version }, compression })
1818
const url = useOffLicense('s3').url(stowage)
1919
const tarball = useCache().path(stowage)
2020
const shelf = tea_prefix.join(pkg.project)
2121

22+
if(env.TEA_MAGIC === "prompt") {
23+
do {
24+
const val = prompt(`┌ ⚠️ Tea requests to install ${pkg.project} (v${pkg.version})\n└ \x1B[1mAllow?\x1B[0m [y/n]`)?.toLowerCase();
25+
// If val is undefined, there was no prompt given since this isn't an interactive tty
26+
if(!val || val === "y") {
27+
break;
28+
}
29+
if(val === "n") {
30+
Deno.exit(1);
31+
}
32+
}
33+
while(true)
34+
}
35+
2236
const log_install_msg = (install: Installation, title = 'installed') => {
2337
if (json) {
2438
logJSON({status: title, pkg: pkgutils.str(install.pkg)})

0 commit comments

Comments
 (0)