1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

BREAKING: make Deno.hostname unstable (#5108)

This commit is contained in:
Ryan Dahl 2020-05-09 12:44:35 -04:00 committed by GitHub
parent eb505f8afc
commit b8364a2636
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 10 deletions

View file

@ -59,7 +59,7 @@ export {
export { metrics, Metrics } from "./ops/runtime.ts";
export { mkdirSync, mkdir, MkdirOptions } from "./ops/fs/mkdir.ts";
export { connect, listen, Listener, Conn } from "./net.ts";
export { dir, env, exit, execPath, hostname } from "./ops/os.ts";
export { dir, env, exit, execPath } from "./ops/os.ts";
export { run, RunOptions, Process, ProcessStatus } from "./process.ts";
export { DirEntry, readDirSync, readDir } from "./ops/fs/read_dir.ts";
export { readFileSync, readFile } from "./read_file.ts";

View file

@ -5,7 +5,7 @@
export { umask } from "./ops/fs/umask.ts";
export { linkSync, link } from "./ops/fs/link.ts";
export { symlinkSync, symlink } from "./ops/fs/symlink.ts";
export { dir, loadavg, osRelease } from "./ops/os.ts";
export { dir, loadavg, osRelease, hostname } from "./ops/os.ts";
export { openPlugin } from "./ops/plugins.ts";
export { transpileOnly, compile, bundle } from "./compiler_api.ts";
export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";

View file

@ -97,14 +97,6 @@ declare namespace Deno {
* */
export function test(name: string, fn: () => void | Promise<void>): void;
/** Get the `hostname` of the machine the Deno process is running on.
*
* console.log(Deno.hostname());
*
* Requires `allow-env` permission.
*/
export function hostname(): string;
/** Exit the Deno process with optional exit code. If no exit code is supplied
* then Deno will exit with return code of 0.
*

View file

@ -1174,4 +1174,12 @@ declare namespace Deno {
state: PermissionState;
constructor(state: PermissionState);
}
/** Get the `hostname` of the machine the Deno process is running on.
*
* console.log(Deno.hostname());
*
* Requires `allow-env` permission.
*/
export function hostname(): string;
}

View file

@ -173,6 +173,7 @@ fn op_hostname(
_args: Value,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<JsonOp, OpError> {
state.check_unstable("Deno.hostname");
state.check_env()?;
let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string());
Ok(JsonOp::Sync(json!(hostname)))