1- import { pkg as pkgutils , TeaError , chuzzle } from "utils"
2- import { ExitError , Installation } from "types"
3- import { useEnv , useConfig , useRun } from "hooks"
4- import { RunError } from "hooks/useRun.ts"
5- import { gray , red , teal } from "hooks/useLogger.ts"
1+ import { useConfig , useRun , useLogger , RunError , Verbosity , ExitError } from "hooks"
2+ import { Installation , Path , utils , TeaError } from "tea"
63import { basename } from "deno/path/mod.ts"
7- import { isNumber } from "is_what"
8- import Path from "path"
4+ import { isNumber } from "is-what"
95
106export default async function ( cmd : string [ ] , env : Record < string , string > ) {
11- const { TEA_FORK_BOMB_PROTECTOR } = useEnv ( )
7+ const { TEA_FORK_BOMB_PROTECTOR } = useConfig ( ) . env
8+ const { red, teal } = useLogger ( )
129
1310 // ensure we cannot fork bomb the user since this is basically the worst thing tea/cli can do
14- let nobomb = chuzzle ( parseInt ( TEA_FORK_BOMB_PROTECTOR ?? '0' ) ) ?? 0
11+ let nobomb = parseInt ( TEA_FORK_BOMB_PROTECTOR ?? '0' ) . chuzzle ( ) ?? 0
1512 env [ 'TEA_FORK_BOMB_PROTECTOR' ] = `${ ++ nobomb } `
1613 if ( nobomb > 20 ) throw new Error ( "FORK BOMB KILL SWITCH ACTIVATED" )
1714
1815 try {
1916 await useRun ( { cmd, env} )
2017 } catch ( err ) {
21- const { debug } = useConfig ( )
18+ const debug = useConfig ( ) . modifiers . verbosity >= Verbosity . debug
2219 const arg0 = cmd ?. [ 0 ]
2320
2421 if ( err instanceof TeaError ) {
@@ -44,8 +41,9 @@ export default async function(cmd: string[], env: Record<string, string>) {
4441}
4542
4643export async function repl ( installations : Installation [ ] , env : Record < string , string > ) {
47- const { SHELL } = useEnv ( )
48- const pkgs_str = ( ) => installations . map ( ( { pkg} ) => gray ( pkgutils . str ( pkg ) ) ) . join ( ", " )
44+ const { SHELL } = useConfig ( ) . env
45+ const { gray } = useLogger ( )
46+ const pkgs_str = ( ) => installations . map ( ( { pkg} ) => gray ( utils . pkg . str ( pkg ) ) ) . join ( ", " )
4947
5048 // going to stderr so that we don’t potentially break (nonsensical) pipe scenarios, eg.
5149 // tea -E | env
@@ -84,7 +82,7 @@ export async function repl(installations: Installation[], env: Record<string, st
8482 }
8583
8684 try {
87- await useRun ( { cmd, env } )
85+ await useRun ( { cmd, env} )
8886 } catch ( err ) {
8987 if ( err instanceof RunError ) {
9088 throw new ExitError ( err . code )
0 commit comments