DenoDDeno
Powered by
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>
deno run --watch <script>
. (e.g.
Deno.addSignalListener('SIGINT', graceful_shutdown)
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
--watch
I do not want to set up shutdown listeners. Is there a way to accomplish this with the
Deno
Deno
global perhaps? My current workaround is to pass some custom flag to my cli script when I am in development, like
--mode=development
--mode=development
or
--no-signal
--no-signal
, but this is a bit confusing for users because this flag is only important for development.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

deno run --watch
lioLlio / help
4y ago
Using Deno.Command to run tailwindcss with watch flag not working
KyleJuneKKyleJune / help
3y ago
Deno Docker - deno run --watch file.ts
SmorSSmor / help
4y ago