I'm running my deno program like this
deno task dev
which corresponds to
deno run --allow-all --watch src/server/main.ts --watch-client
Within my main.ts
I want to get the current full Deno command, not just the args (so either deno task dev
or deno run --allow-all --watch src/server/main.ts --watch-client
).
Deno.args
doesn't help as it returns only ['--watch-client']
.
edit:
One way could be using Deno.pid
as reference and run
Get-WmiObject Win32_Process -Filter "ProcessId = 27096"
(where 27096 is my Deno.pid
) and then parse output an look for CommandLine
, but it's PowerShell / Windows only
edit2: I managed obtaining the information in Windows via powershell like this:
const command = new Deno.Command("powershell.exe", {
args: [`Get-WmiObject Win32_Process -Filter "ProcessId = ${Deno.pid}"`]
})
const out = await command.output();
const info = new TextDecoder().decode(out.stdout);
const commandLine = /^CommandLine\s*:\s*(.*)$/gm.exec(info)![1];
console.log(commandLine);
However I'm still looking for a more cross platform solution