0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/cli/tests/testdata/permission_test.ts
2022-05-18 22:00:11 +02:00

30 lines
762 B
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const name = Deno.args[0];
// deno-lint-ignore no-explicit-any
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
readRequired() {
Deno.readFileSync("hello.txt");
return Promise.resolve();
},
writeRequired() {
Deno.makeTempDirSync();
},
envRequired() {
Deno.env.get("home");
},
netRequired() {
Deno.listen({ transport: "tcp", port: 4541 });
},
async runRequired() {
await Deno.spawn(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
args: Deno.build.os === "windows" ? ["/c", "echo hello"] : ["hello"],
});
},
};
if (!test[name]) {
console.log("Unknown test:", name);
Deno.exit(1);
}
test[name]();