How to run a command with a different working directory?

In Deno, I know that I can run a command like so:

const process = Deno.run({
  cmd: ["echo", "hello world"]
})

How can I run my command with a different working directory?

Answers 1

  • Use cwd to specify a different path relative to your working directory (or use an absolute path).

    const process = Deno.run({
      cmd: ["echo", "hello world"],
      cwd: "/path/to/dir"
    })
    

Related Articles