diff --git a/cli/js/deno.ts b/cli/js/deno.ts index 38b2f6d2ad..5843d5fbfc 100644 --- a/cli/js/deno.ts +++ b/cli/js/deno.ts @@ -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"; diff --git a/cli/js/deno_unstable.ts b/cli/js/deno_unstable.ts index 57d1a0970f..4d964f3bd4 100644 --- a/cli/js/deno_unstable.ts +++ b/cli/js/deno_unstable.ts @@ -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"; diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 1eeb863073..8c91f145e3 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -97,14 +97,6 @@ declare namespace Deno { * */ export function test(name: string, fn: () => void | Promise): 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. * diff --git a/cli/js/lib.deno.unstable.d.ts b/cli/js/lib.deno.unstable.d.ts index a523300ccc..10587d3dfb 100644 --- a/cli/js/lib.deno.unstable.d.ts +++ b/cli/js/lib.deno.unstable.d.ts @@ -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; } diff --git a/cli/ops/os.rs b/cli/ops/os.rs index d9a6b30958..6c18015207 100644 --- a/cli/ops/os.rs +++ b/cli/ops/os.rs @@ -173,6 +173,7 @@ fn op_hostname( _args: Value, _zero_copy: Option, ) -> Result { + state.check_unstable("Deno.hostname"); state.check_env()?; let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string()); Ok(JsonOp::Sync(json!(hostname)))