Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
How to determine the location of the deno script?

Let's say I issue the following command:

deno run --allow-read /scripts/where-am-i.ts

What would need to be inside where-am-i.ts for it to output:

/scripts

I've tried:

console.log(Deno.cwd());

which prints the directory the script was called from (/ in this example).

I have also tried:

console.log(Deno.execPath());

which prints the location of the deno binary (~/.cargo/bin/deno for me).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use some utilities from the std/path module to determine the directory of a module, based on its import meta:

so-72156289.ts:

import * as path from "https://deno.land/std@0.138.0/path/mod.ts";

function getModuleDir(importMeta: ImportMeta): string {
  return path.resolve(path.dirname(path.fromFileUrl(importMeta.url)));
}

const dir = getModuleDir(import.meta);
console.log(dir);

$ deno run /Users/deno/examples/so-72156289.ts
/Users/deno/examples

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda