dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
970 stars 33 forks source link

fix: don't require `--allow-net` #158

Closed NfNitLoop closed 11 months ago

NfNitLoop commented 11 months ago

This relates to conversation in #31

It looks like the module actually loads faster with the embedded wasm file, despite it being larger and requiring base64-decoding.

Before 0697afd:

〉deno task bench
Task bench deno bench -A
cpu: AMD Ryzen 7 3700X 8-Core Processor
runtime: deno 1.35.3 (x86_64-pc-windows-msvc)

file:///C:/Users/Cody/code/dax/benchmarks/mod.bench.ts
benchmark           time (avg)             (min … max)       p75       p99      p995
------------------------------------------------------ -----------------------------
loadWasmModule      83.62 ms/iter   (81.72 ms … 86.68 ms)  83.93 ms  86.68 ms  86.68 ms

After 0697afd:

benchmark           time (avg)             (min … max)       p75       p99      p995
------------------------------------------------------ -----------------------------
loadWasmModule      80.41 ms/iter   (79.28 ms … 83.79 ms)  80.47 ms  83.79 ms  83.79 ms

This also removes the need to --allow-write or --allow-net:

#!/usr/bin/env -S deno run --allow-env --allow-read
// ⬆️ New 🎉

// old:
// #!/usr/bin/env -S deno run --allow-env --allow-read --allow-write  --allow-net

import $ from "https://raw.githubusercontent.com/NfNitLoop/dax/0697afdbee91a866288214327fad04cc63a57b67/mod.ts"

await $`pwd`.printCommand()
NfNitLoop commented 11 months ago

Not all tests pass on Windows, but that seems to have been the case for me before my changes as well.