1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 00:59:24 -05:00
denoland-deno/cli/tests/permission_test.ts

34 lines
796 B
TypeScript
Raw Normal View History

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const name = Deno.args[0];
// deno-lint-ignore no-explicit-any
2020-08-24 19:43:54 -04:00
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
2020-03-20 09:38:34 -04:00
readRequired(): Promise<void> {
Deno.readFileSync("README.md");
2020-03-20 09:38:34 -04:00
return Promise.resolve();
},
writeRequired(): void {
Deno.makeTempDirSync();
},
envRequired(): void {
Deno.env.get("home");
},
netRequired(): void {
Deno.listen({ transport: "tcp", port: 4541 });
},
runRequired(): void {
const p = Deno.run({
cmd: Deno.build.os === "windows"
? ["cmd.exe", "/c", "echo hello"]
: ["printf", "hello"],
});
p.close();
},
};
if (!test[name]) {
console.log("Unknown test:", name);
Deno.exit(1);
}
test[name]();