Skip to content

Commit

Permalink
feat: TEA_MAGIC=prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
lino-levan authored and mxcl committed Apr 27, 2023
1 parent 4b2c03a commit 28de02a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Env {
TEA_DIR?: string
TEA_FILES?: string
TEA_FORK_BOMB_PROTECTOR?: string
TEA_MAGIC?: string
TEA_PANTRY_PATH?: string
TEA_PKGS?: string
TEA_PREFIX?: string
Expand Down
1 change: 1 addition & 0 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function collectEnv(): Env {
TEA_DIR: Deno.env.get("TEA_DIR"),
TEA_FILES: Deno.env.get("TEA_FILES"),
TEA_FORK_BOMB_PROTECTOR: Deno.env.get("TEA_FORK_BOMB_PROTECTOR"),
TEA_MAGIC: Deno.env.get("TEA_MAGIC"),
TEA_PANTRY_PATH: Deno.env.get("TEA_PANTRY_PATH"),
TEA_PKGS: Deno.env.get("TEA_PKGS"),
TEA_PREFIX: Deno.env.get("TEA_PREFIX"),
Expand Down
16 changes: 15 additions & 1 deletion src/prefab/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ export default async function install(pkg: Package, logger?: Logger): Promise<In

const cellar = useCellar()
const tea_prefix = usePrefix()
const { isCI, dryrun, json } = useConfig()
const { isCI, dryrun, json, env } = useConfig()
const compression = get_compression(isCI)
const stowage = StowageNativeBottle({ pkg: { project, version }, compression })
const url = useOffLicense('s3').url(stowage)
const tarball = useCache().path(stowage)
const shelf = tea_prefix.join(pkg.project)

if(env.TEA_MAGIC === "prompt") {
do {
const val = prompt(`┌ ⚠️ Tea requests to install ${pkg.project} (v${pkg.version})\n└ \x1B[1mAllow?\x1B[0m [y/n]`)?.toLowerCase();
// If val is undefined, there was no prompt given since this isn't an interactive tty
if(!val || val === "y") {
break;
}
if(val === "n") {
Deno.exit(1);
}
}
while(true)
}

const log_install_msg = (install: Installation, title = 'installed') => {
if (json) {
logJSON({status: title, pkg: pkgutils.str(install.pkg)})
Expand Down

0 comments on commit 28de02a

Please sign in to comment.