diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2019-11-12 00:33:29 +0900 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-11 10:33:29 -0500 |
commit | 31115067cd3156db1ead0dc0f11c78875840dc4f (patch) | |
tree | b8e4cb2447bb7a8e8e0a8f1bc158760394ed9b66 /cli/js/permissions.ts | |
parent | b3baab6d1479abbfd2e534fe05f5e146c2d5b1a2 (diff) |
Add permissions.request (#3296)
Diffstat (limited to 'cli/js/permissions.ts')
-rw-r--r-- | cli/js/permissions.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/js/permissions.ts b/cli/js/permissions.ts index 16ea3e5c2..c3530e970 100644 --- a/cli/js/permissions.ts +++ b/cli/js/permissions.ts @@ -68,6 +68,19 @@ export class Permissions { const { state } = sendSync(dispatch.OP_REVOKE_PERMISSION, desc); return new PermissionStatus(state); } + + /** Requests the permission. + * const status = await Deno.permissions.request({ name: "env" }); + * if (status.state === "granted") { + * console.log(Deno.homeDir()); + * } else { + * console.log("'env' permission is denied."); + * } + */ + async request(desc: PermissionDescriptor): Promise<PermissionStatus> { + const { state } = sendSync(dispatch.OP_REQUEST_PERMISSION, desc); + return new PermissionStatus(state); + } } export const permissions = new Permissions(); |