mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: first pass at native plugins (#3372)
This commit is contained in:
parent
214b3eb29a
commit
7c3b9b4f4f
26 changed files with 574 additions and 7 deletions
|
@ -26,6 +26,7 @@ interface TestPermissions {
|
|||
net?: boolean;
|
||||
env?: boolean;
|
||||
run?: boolean;
|
||||
plugin?: boolean;
|
||||
hrtime?: boolean;
|
||||
}
|
||||
|
||||
|
@ -35,6 +36,7 @@ export interface Permissions {
|
|||
net: boolean;
|
||||
env: boolean;
|
||||
run: boolean;
|
||||
plugin: boolean;
|
||||
hrtime: boolean;
|
||||
}
|
||||
|
||||
|
@ -48,6 +50,7 @@ async function getProcessPermissions(): Promise<Permissions> {
|
|||
write: await isGranted("write"),
|
||||
net: await isGranted("net"),
|
||||
env: await isGranted("env"),
|
||||
plugin: await isGranted("plugin"),
|
||||
hrtime: await isGranted("hrtime")
|
||||
};
|
||||
}
|
||||
|
@ -75,8 +78,9 @@ function permToString(perms: Permissions): string {
|
|||
const n = perms.net ? 1 : 0;
|
||||
const e = perms.env ? 1 : 0;
|
||||
const u = perms.run ? 1 : 0;
|
||||
const p = perms.plugin ? 1 : 0;
|
||||
const h = perms.hrtime ? 1 : 0;
|
||||
return `permR${r}W${w}N${n}E${e}U${u}H${h}`;
|
||||
return `permR${r}W${w}N${n}E${e}U${u}P${p}H${h}`;
|
||||
}
|
||||
|
||||
function registerPermCombination(perms: Permissions): void {
|
||||
|
@ -93,6 +97,7 @@ function normalizeTestPermissions(perms: TestPermissions): Permissions {
|
|||
net: !!perms.net,
|
||||
run: !!perms.run,
|
||||
env: !!perms.env,
|
||||
plugin: !!perms.plugin,
|
||||
hrtime: !!perms.hrtime
|
||||
};
|
||||
}
|
||||
|
@ -120,6 +125,7 @@ export function test(fn: testing.TestFunction): void {
|
|||
net: false,
|
||||
env: false,
|
||||
run: false,
|
||||
plugin: false,
|
||||
hrtime: false
|
||||
},
|
||||
fn
|
||||
|
@ -176,6 +182,7 @@ test(function permissionsMatches(): void {
|
|||
net: false,
|
||||
env: false,
|
||||
run: false,
|
||||
plugin: false,
|
||||
hrtime: false
|
||||
},
|
||||
normalizeTestPermissions({ read: true })
|
||||
|
@ -190,6 +197,7 @@ test(function permissionsMatches(): void {
|
|||
net: false,
|
||||
env: false,
|
||||
run: false,
|
||||
plugin: false,
|
||||
hrtime: false
|
||||
},
|
||||
normalizeTestPermissions({})
|
||||
|
@ -204,6 +212,7 @@ test(function permissionsMatches(): void {
|
|||
net: true,
|
||||
env: true,
|
||||
run: true,
|
||||
plugin: true,
|
||||
hrtime: true
|
||||
},
|
||||
normalizeTestPermissions({ read: true })
|
||||
|
@ -219,6 +228,7 @@ test(function permissionsMatches(): void {
|
|||
net: true,
|
||||
env: false,
|
||||
run: false,
|
||||
plugin: false,
|
||||
hrtime: false
|
||||
},
|
||||
normalizeTestPermissions({ read: true })
|
||||
|
@ -234,6 +244,7 @@ test(function permissionsMatches(): void {
|
|||
net: true,
|
||||
env: true,
|
||||
run: true,
|
||||
plugin: true,
|
||||
hrtime: true
|
||||
},
|
||||
{
|
||||
|
@ -242,6 +253,7 @@ test(function permissionsMatches(): void {
|
|||
net: true,
|
||||
env: true,
|
||||
run: true,
|
||||
plugin: true,
|
||||
hrtime: true
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue