Skip to content

Commit

Permalink
if neither CLT or Xcode installed then don’t x git
Browse files Browse the repository at this point in the history
Because `git` fails in those cases, and thus our installer fails and `tea --sync` fails.

Instead use the fallback method where we download the tarballs.
  • Loading branch information
mxcl committed Oct 26, 2022
1 parent e203fb9 commit f2d016e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ that part; it’s going to *change the world*.
 


# tea/cli 0.10.0
# tea/cli 0.10.1

tea is a universal virtual‑environment manager:

Expand Down
14 changes: 13 additions & 1 deletion src/hooks/usePantry.git.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useDownload, usePrefix, useCellar } from "hooks"
import * as semver from "semver"
import { run } from "utils"
import { host, run } from "utils"
import Path from "path"

export const prefix = usePrefix().join('tea.xyz/var/pantry/projects')

async function find_git(): Promise<Path | undefined> {
for (const path_ of Deno.env.get('PATH')?.split(':') ?? []) {
const path = Path.root.join(path_, 'git')
if (path.string == '/usr/bin/git' && host().platform == 'darwin' && !await clt_installed()) {
// if the CLT or Xcode is installed then we can use the system git
// if neither is installed then git will actually immediately exit with an error
continue
}
if (path.isExecutableFile()) {
return Promise.resolve(path)
}
Expand All @@ -21,6 +26,13 @@ async function find_git(): Promise<Path | undefined> {
// there's no pantry yet, so attempting to do so will infinitely recurse
}

async function clt_installed() {
// returns either the CLT path or the Xcode path
const proc = Deno.run({ cmd: ["xcode-select", "--print-path"], stdio: 'null' })
const exit = await proc.status()
return exit.success
}

const pantry_dir = prefix.parent()
const pantries_dir = pantry_dir.parent().join("pantries")

Expand Down

0 comments on commit f2d016e

Please sign in to comment.