-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
Here's an example script prompting for read permissions:
const desc: Deno.ReadPermissionDescriptor = { name: "read" };
const status = await Deno.permissions.query(desc);
console.log("Before request:", status);
await Deno.permissions.request(desc);
console.log("After request:", status);
await Deno.readTextFile("example.ts");When I run the script, piping the output of another process to it, I am never shown the permission prompt (it is automatically denied):
% cat example.ts | deno run example.ts
Before request: PermissionStatus { state: "prompt", onchange: null }
After request: PermissionStatus { state: "denied", onchange: null }
error: Uncaught (in promise) PermissionDenied: Requires read access to "example.ts", run again with the --allow-read flag
await Deno.readTextFile("example.ts");
^
at unwrapOpResult (deno:core/core.js:100:13)
at async open (deno:runtime/js/40_files.js:46:17)
at async Object.readTextFile (deno:runtime/js/40_read_file.js:40:18)
at async file:///Users/jesse/example/example.ts:9:1
But if I simply run the script, I am presented the prompt:
% deno run example.ts
Before request: PermissionStatus { state: "prompt", onchange: null }
⚠️ ️Deno requests read access. Grant? [g/d (g = grant, d = deny)] g
After request: PermissionStatus { state: "granted", onchange: null }
This example script does not need data from stdin, but if another one did, how could it get it while still being able to prompt for permissions?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels