0

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

2
  • Deno does not currently offer this type of introspection — any solution would apply equally to other non-Deno processes, so I've removed the deno tag from the question. If there is something specific to Deno that should be added to the question, feel free to clarify with an edit. Commented Feb 15 at 19:28
  • 1
    For Linux, see How to get whole command line from a process? Commented Feb 15 at 19:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.