andykaisA
Denoβ€’3y agoβ€’
2 replies
andykais

How to detect when --watch flag has been passed to `deno run` programatically?

I am writing a small cli script, and I have a few bits of code that do not play nicely with
deno run --watch <script>
. (e.g.
Deno.addSignalListener('SIGINT', graceful_shutdown)
. What I want to do is only set up that listener when I am running my cli app in 'production mode'. E.g. while I am developing the cli app with
--watch
I do not want to set up shutdown listeners. Is there a way to accomplish this with the
Deno
global perhaps? My current workaround is to pass some custom flag to my cli script when I am in development, like
--mode=development
or
--no-signal
, but this is a bit confusing for users because this flag is only important for development.
Was this page helpful?