iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📝

Configuring Zenn CLI for Deno

に公開

Zenn CLI is intended to be used with Node.js, but I tried using it with Deno.

deno.json

For security reasons, I have restricted the permissions strictly. It might still fail depending on your environment.

{
  "imports": {
    "zenn-cli": "npm:zenn-cli@^0.2.3"
  },
  "tasks": {
    "zenn": "deno run --allow-read=.,/proc/version,/proc/self,/.dockerenv,\"$HOME/.config\",\"$USERPROFILE\\.config\" --allow-write=.,\"$HOME/.config\",\"$USERPROFILE\\.config\" --allow-net=0.0.0.0,registry.npmjs.org:443,zenn.dev:443 --allow-env --allow-sys=homedir,osRelease zenn-cli"
  }
}
  • Updated to work on both Windows and Podman.

Explanation

Here is an explanation of the command argument specifications.

  1. Backslashes are used to include quotes within the strings in the JSON file (single quotes could also have been used, so this is a matter of personal preference).

  2. In Deno, $HOME worked even on Windows (no need to use %USERPROFILE% or $env:USERPROFILE).

  3. Using an environment variable alone for a path results in an error if the variable is undefined, so specify a sub-directory where possible (if the variable is undefined, it ends up being a path from the root, but this is unavoidable without conditional logic).

Discussion