muesli / termenv

Advanced ANSI style & color support for your terminal applications
MIT License
1.71k stars 68 forks source link

add support for GOARCH=wasm (include GOOS=wasip1) #168

Open amadigan opened 4 months ago

amadigan commented 4 months ago

termenv compiles where GOOS=js, but fails with GOOS=wasip1 (https://go.dev/blog/wasi). This patch treats wasip1 as js, which for these purposes should be correct.

I was able to run the tests on wasip1 by installing wazero and setting WASMRUNTIME=wazero. The tests failed, when I first ran them, but it looks like the tests make assumptions that would fail for all of the _other targets. This patch also "fixes" the tests (it skips one I wasn't sure how to rewrite for this platform).

A project I'm working on imports this library as a transitive dependency, without this termenv does not build on GOOS=wasip1.

I decided to target wasm rather than js and wasip1 because more GOOS values will probably be added for wasm in the future, but it seems unlikely that wasm will end up running full operating systems tag like 'unix' would apply to.