summaryrefslogtreecommitdiff
path: root/cli/js/permissions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/permissions.ts')
-rw-r--r--cli/js/permissions.ts13
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();