Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into v0.26
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/app.ts
  • Loading branch information
mxcl committed Mar 26, 2023
2 parents c77fffa + 68d1902 commit a6193f0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 19 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

<p align="center">
<a href="https://twitter.com/teaxyz">
<img src="https://img.shields.io/twitter/follow/teaxyz?style=flat&label=%40teaxyz&logo=twitter&color=2675f5&logoColor=fff" alt="Twitter" />
<img src="https://img.shields.io/badge/-teaxyz-2675f5?logo=twitter&logoColor=fff" alt="Twitter" />
</a>
<a href="https://discord.tea.xyz">
<img src="https://img.shields.io/discord/906608167901876256?label=discord&color=29f746" alt="Discord" />
<img src="https://img.shields.io/discord/906608167901876256?label=discord&color=1bcf6f&logo=discord&logoColor=fff" alt="Discord" />
</a>
<a href='https://coveralls.io/github/teaxyz/cli?branch=main'>
<img src='https://coveralls.io/repos/github/teaxyz/cli/badge.svg?branch=main' alt='Coverage Status' />
</a>
<a href="https://docs.tea.xyz">
<img src="https://img.shields.io/badge/-docs-2675f5?logoColor=fff&color=ff00ff&logo=gitbook" alt="Documentation & Manual" />
</a>
</p>


# tea/cli 0.25.2
# tea/cli 0.25.3

`tea` puts the whole open source ecosystem at your fingertips:

Expand Down
2 changes: 1 addition & 1 deletion src/app.dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default async function dump({ env, shell }: Parameters) {

// print the setters for the new env
for (const [key, value] of Object.entries(env)) {
await print(set(key, value))
if (value) await print(set(key, value))
}
await print(set('TEA_REWIND', TEA_REWIND))

Expand Down
2 changes: 1 addition & 1 deletion src/app.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function run(args: Args) {
break
case "dump": {
env['PATH'] = full_path().join(':')
env["TEA_PKGS"] = pkgs.map(pkgutils.str).join(":")
env["TEA_PKGS"] = pkgs.map(pkgutils.str).join(":").trim()
env["TEA_PREFIX"] ??= usePrefix().string
env["TEA_VERSION"] = useVersion()

Expand Down
1 change: 0 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { parseArgs } from "./args.ts";
import { init } from "./init.ts";
import useConfig from "./hooks/useConfig.ts";


try {
const [args, flags] = parseArgs(Deno.args, Deno.execPath())
init(flags)
Expand Down
60 changes: 47 additions & 13 deletions tests/integration/magic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ it(suite, "tea --magic in a script. bash", async function() {
})

it(suite, "tea --magic in a script. fish", async function() {
// fish doesn’t error if there's an error when sourcing our magic script
// so instead we verify each part of our magic is working separately

const script = this.sandbox.join("magic-fish").write({ text: undent`
#!/usr/bin/fish
Expand All @@ -63,27 +66,58 @@ it(suite, "tea --magic in a script. fish", async function() {
set N 4
end
if which node
exit 2
end
test $(basename $(ps -hp $fish_pid | awk "{print \\$$N}" | tail -n1)) = fish
tea --magic=fish | source
export NODE_DISABLE_COLORS=1
export CLICOLOR_FORCE=0
export VERBOSE=-1 # no tea output FIXME doesn’t seem to work…?
node^18 --eval "console.log('xyz')"
# we write a file because currently there's a bug where
# fish cannot redirect from the command not found handler
node^18 --eval "require('fs').writeFileSync('node.out', 'xyz.tea.hi')"
if test "$(cat node.out)" != xyz.tea.hi
exit 3
end
# check again
if which node
exit 2
end
echo 'dependencies: { node: ^18 }' > ./tea.yaml
cd .
node --version
`})

// fish forces all output to stderr when running in the command not found handler
const out = await this.run({ args: [script.string] }).stdout()
await this.run({ args: [script.string] })
})


it(suite, "tea verify --magic is parsed correctly by fish", async function() {
const script = this.sandbox.join("magic-fish").write({ text: undent`
#!/usr/bin/fish
tea --magic=fish | source
`})

// fish doesn't have an equivalent of bash's "set -e" to exit the script if an error occurs
// for more information go here: https://github.com/fish-shell/fish-shell/issues/510
// we will assume if stderr contains anything that isn't prefixed with tea that then
// an error occurred
const stderr = await this.run({ args: [script.string] }).stderr()

// splitting it as stderr includes our output
//FIXME I can't stop it doing color codes whatever I try
let asserted = false
for (const line of out.split("\n").compact(x => strip_ansi_escapes(x).trim())) {
if (line.startsWith("tea:")) continue
assertEquals(line, "xyz", `hi: ${line}`)
asserted = true
break
}
assert(asserted)
const errorLines = stderr.split("\n")
.compact(x => strip_ansi_escapes(x).trim())
.filter(x => !x.startsWith("tea:"))
assertEquals(errorLines, [])
})

0 comments on commit a6193f0

Please sign in to comment.