1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/tools/permission_prompt_test.ts
Ryan Dahl 97bb2bdb79
dial/listen API change (#3000)
Previously: dial("tcp", "deno.land:80")
Now: dial({ hostname: "deno.land", port: 80, transport: "tcp" })
Similarly with listen().
2019-09-20 18:32:18 -04:00

67 lines
1.4 KiB
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { args, env, exit, makeTempDirSync, readFileSync, run } = Deno;
const firstCheckFailedMessage = "First check failed";
const name = args[1];
const test = {
async needsRead(): Promise<void> {
try {
readFileSync("package.json");
} catch (e) {
console.log(firstCheckFailedMessage);
}
readFileSync("package.json");
},
needsWrite(): void {
try {
makeTempDirSync();
} catch (e) {
console.log(firstCheckFailedMessage);
}
makeTempDirSync();
},
needsEnv(): void {
try {
env().home;
} catch (e) {
console.log(firstCheckFailedMessage);
}
env().home;
},
needsNet(): void {
try {
Deno.listen({ hostname: "127.0.0.1", port: 4540 });
} catch (e) {
console.log(firstCheckFailedMessage);
}
Deno.listen({ hostname: "127.0.0.1", port: 4541 });
},
needsRun(): void {
try {
run({
args: [
"python",
"-c",
"import sys; sys.stdout.write('hello'); sys.stdout.flush()"
]
});
} catch (e) {
console.log(firstCheckFailedMessage);
}
run({
args: [
"python",
"-c",
"import sys; sys.stdout.write('hello'); sys.stdout.flush()"
]
});
}
}[name];
if (!test) {
console.log("Unknown test:", name);
exit(1);
}
test();