Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append --allow-* flags only to "deno run" commands #111

Open
vintprox opened this issue Nov 26, 2020 · 0 comments
Open

Append --allow-* flags only to "deno run" commands #111

vintprox opened this issue Nov 26, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@vintprox
Copy link

vintprox commented Nov 26, 2020

Is your feature request related to a problem? Please describe.
The usual (and expected) behavior behind top-level allow script option is that it's merged with allow of subsequent script. This isn't problem at all.

But why --allow-* flags are being added to any command besides "deno run"? For example, whenever these are appended to "deno cache", it will complain about unexpected flags. Notice again that top-level allow is sebsequently inherited by all scripts. These flags are mostly specific to "deno run" only.

Describe the solution you'd like
Add condition to check whether full command starts with "deno run" and append --allow-* flags only when this condition is satisfied.

Describe alternatives you've considered
As workaround, I plant allow option individually on each script that involves "deno run".

Additional context

import { DenonConfig } from "https://deno.land/x/denon@2.4.5/mod.ts";

const config: DenonConfig = {
  allow: {
    net: true,
  },
  lock: "lock.json",
  scripts: {
    start: {
      cmd: "src/bot.ts",
      desc: "Start the bot",
    },
    lock: {
      cmd: "deno cache --lock-write src/bot.ts",
      desc: "Lock dependencies for integrity checking",
    },
  },
};

export default config;

Denon resolves "lock" script to:

$ deno cache --allow-net --lock lock.json --lock-write src/bot.ts

To which "deno cache" returns error:

error: Found argument '--allow-net' which wasn't expected, or isn't valid in this context

It can happen basically with any command besides "deno run".

@vintprox vintprox added the enhancement New feature or request label Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant