Skip to content

Commit

Permalink
Improve error message for tea . in non-venvs
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Nov 8, 2022
1 parent 12b7d4f commit b24660f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/app.exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export default async function exec(opts: Args) {

try {
if (cmd.length) {
if (cmd[0] == '.') {
// if we got here and `.` wasn’t converted into something else
// then there was no default target or no exe/md and running `.`
// will just give a cryptic message, so let’s provide a better one
throw new TeaError('not-found: exe/md: default target', {opts})
}

await run({ cmd, env }) //TODO implement `execvp` for deno
} else if (opts.pkgs.length) {
await repl(installations, env)
Expand Down
12 changes: 6 additions & 6 deletions src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export default class TeaError extends Error {
msg = `target \`${ctx.name}' contains no script region`
break
case 'not-found: exe/md: default target':
msg = undent`
default target not found:
${ctx.requirementsFile}
`
break
if (ctx.requirementsFile) {
msg = `default target not found in \`${ctx.requirementsFile}'`
} else {
msg = "no `README' or `package.json' found"
}
break
case 'http':
msg = ctx.underr?.message ?? "contact violated"
break
Expand Down

0 comments on commit b24660f

Please sign in to comment.