A dexterous deno executor (only for development)
Commentary article in Japanese: https://zenn.dev/kawarimidoll/articles/d371abbd46b65b
Install by deno install
:
deno install --allow-read --allow-write --allow-run --reload --force --name dex https://pax.deno.dev/kawarimidoll/deno-dex/main.ts
The reasons why these permissions are required are:
read
: to watch file changes and current working directorywrite
: to save intermediate script file in$DENO_DIR
run
: to run and kill process
- Run
deno run
ordeno test
for the file as argument.- Detect the file is for test or not.
- Add
--allow-all --unstable --no-check --watch
for fast development.
- There are several options.
--clear
: Clear console every restart.--watch
: Watch changes of any files you specified.- Other options are passed to
deno run
ordeno test
transparently.
- Auto-detect
import maps
and
configuration files.
- When
dex
starts without--import-map
option and there isimport_map.json
,--import-map=import_map.json
is implicitly added. - When
dex
starts without--config
option and there is one ofdeno.jsonc
,deno.json
ortsconfig.json
,--config=[one of them]
is implicitly added. - The arguments of
--import-map
and--config
are also passed to--watch
option ofdex
.
- When
Run the file by deno run
:
dex hello.ts
# -> deno run --allow-all --unstable --no-check --watch hello.ts
Test the file by deno test
if the file is
test file:
dex hello_test.ts
# -> deno test --allow-all --unstable --no-check --watch hello_test.ts
For more details, see help:
dex --help
As written above, dex
skips all checks (--allow-all --unstable --no-check
).
This increases productivity in development, but decreases security. Use it only
for your own code.
When Deno.exit()
is called,
process will be stopped without restarting. This is same as normal
deno run --watch
behavior.
If you using Vim or Neovim, put the definition below in your configuration file
to enable :Dex
command.
command! -nargs=* -bang Dex silent only! | botright 12 split |
\ execute 'terminal' (has('nvim') ? '' : '++curwin') 'dex'
\ (<bang>0 ? '--clear' : '') <q-args> expand('%:p') |
\ stopinsert | execute 'normal! G' | set bufhidden=wipe |
\ execute 'autocmd BufEnter <buffer> if winnr("$") == 1 | quit! | endif' |
\ wincmd k
:Dex
to rundex
with the current file in the terminal window under editor area.:Dex
accepts runtime options, like as:Dex --quite
:Dex!
is shorthand of:Dex --clear
--watch
option is heavily inspired by this article.
Build a live reloader and explore Deno! 🦕 - DEV Community
if (this.repo.isAwesome || this.repo.isHelpful) {
star(this.repo);
}