Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Not sure why we don’t need to close the file. I assume the streaming infra does this for us.

Either way, it errors if we try to on linux
  • Loading branch information
mxcl committed Mar 14, 2023
1 parent 8b3bc86 commit 4640db5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ $ docker run --rm -it teaxyz/cli
> $ sudo install -m 755 <(curl --compressed -LSsf https://tea.xyz/$(uname)/$(uname -m)) /usr/local/bin/tea
> ```
>
> On macOS you may need to unquarantine the binary before it will execute:
> ### Unquarantining on macOS
>
> If the macOS GateKeeper says no try this:
>
> ```sh
> # download from https://github.com/teaxyz/cli/releases first
Expand Down
11 changes: 2 additions & 9 deletions src/hooks/useDownload.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { readerFromStreamReader } from "deno/streams/reader_from_stream_reader.ts"
import { copy } from "deno/streams/copy.ts"
import { crypto, toHashString } from "deno/crypto/mod.ts"
import { Logger, teal, gray } from "./useLogger.ts"
import { chuzzle, error, TeaError } from "utils"
import { crypto, toHashString } from "deno/crypto/mod.ts";
import { useFlags, usePrefix } from "hooks"
import { isString } from "is_what"
import Path from "path"


interface DownloadOptions {
src: URL
headers?: Record<string, string>
Expand Down Expand Up @@ -113,11 +110,7 @@ async function download(opts: DownloadOptions): Promise<Path> {

path.parent().mkpath()
const f = await Deno.open(path.string, {create: true, write: true, truncate: true})
try {
await stream.pipeTo(f.writable)
} finally {
f.close()
}
await stream.pipeTo(f.writable)
return path
} catch (cause) {
throw new TeaError('http', {cause, ...opts})
Expand Down
2 changes: 1 addition & 1 deletion src/prefab/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default async function install(pkg: Package, logger?: Logger): Promise<In

const tmpdir = usePrefix().join("tmp").mkpath()
const untar = new Deno.Command("tar", {
args: [tar_args, "-"],
args: [tar_args],
stdin: 'piped', stdout: "inherit", stderr: "inherit",
cwd: tmpdir.string,
}).spawn()
Expand Down
9 changes: 2 additions & 7 deletions tests/integration/tea.ln.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import suite from "../integration.suite.ts"
import { it } from "deno/testing/bdd.ts"
import Path from "path"

// temporary until node bottles are not crashing on macOS again
if (Deno.build.os != 'darwin' || !Deno.env.get("GITHUB_ACTIONS")) {

async function run(cmd: string[], PATH: Path, TEA_PREFIX: Path) {
const proc = Deno.run({
cmd,
stdout: "piped",
env: {
PATH: PATH.string,
PATH: `${PATH}:/usr/bin:/bin`,
TEA_PREFIX: TEA_PREFIX.string
}
})
Expand All @@ -20,7 +17,7 @@ async function run(cmd: string[], PATH: Path, TEA_PREFIX: Path) {
try {
const { success } = await proc.status()
out = new TextDecoder().decode(await proc.output())
if (!success) console.error("error:", `stdout: out`)
if (!success) console.error("error:", `stdout: ${out}`)
assert(success, out)
} finally {
if (out === undefined) proc.stdout!.close()
Expand Down Expand Up @@ -72,5 +69,3 @@ it(suite, "hardlinks work", async function() {
const out = await run(['node', "--eval", "console.log('hello')"], node.parent(), this.TEA_PREFIX)
assertEquals(out, "hello\n", out)
})

}

0 comments on commit 4640db5

Please sign in to comment.