mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
feat: Stabilize Deno.mainModule (#6993)
This commit is contained in:
parent
6fcf06306e
commit
52c1017a74
6 changed files with 8 additions and 14 deletions
3
cli/dts/lib.deno.ns.d.ts
vendored
3
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -2025,4 +2025,7 @@ declare namespace Deno {
|
||||||
* called when `Deno.inspect()` is called, or when the object is logged to
|
* called when `Deno.inspect()` is called, or when the object is logged to
|
||||||
* the console. */
|
* the console. */
|
||||||
export const customInspect: unique symbol;
|
export const customInspect: unique symbol;
|
||||||
|
|
||||||
|
/** The URL of the entrypoint module entered from the command-line. */
|
||||||
|
export const mainModule: string;
|
||||||
}
|
}
|
||||||
|
|
9
cli/dts/lib.deno.unstable.d.ts
vendored
9
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -1098,9 +1098,6 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function hostname(): string;
|
export function hostname(): string;
|
||||||
|
|
||||||
/** **UNSTABLE**: The URL of the file that was originally executed from the command-line. */
|
|
||||||
export const mainModule: string;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted.
|
/** **UNSTABLE**: new API, yet to be vetted.
|
||||||
* Synchronously truncates or extends the specified file stream, to reach the
|
* Synchronously truncates or extends the specified file stream, to reach the
|
||||||
* specified `len`. If `len` is not specified then the entire file contents
|
* specified `len`. If `len` is not specified then the entire file contents
|
||||||
|
@ -1217,7 +1214,7 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
* A custom HttpClient for use with `fetch`.
|
* A custom HttpClient for use with `fetch`.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
||||||
* const req = await fetch("https://myserver.com", { client });
|
* const req = await fetch("https://myserver.com", { client });
|
||||||
|
@ -1233,7 +1230,7 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
interface CreateHttpClientOptions {
|
interface CreateHttpClientOptions {
|
||||||
/** A certificate authority to use when validating TLS certificates.
|
/** A certificate authority to use when validating TLS certificates.
|
||||||
*
|
*
|
||||||
* Requires `allow-read` permission.
|
* Requires `allow-read` permission.
|
||||||
*/
|
*/
|
||||||
caFile?: string;
|
caFile?: string;
|
||||||
|
@ -1241,7 +1238,7 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
* Create a custom HttpClient for to use with `fetch`.
|
* Create a custom HttpClient for to use with `fetch`.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
||||||
* const req = await fetch("https://myserver.com", { client });
|
* const req = await fetch("https://myserver.com", { client });
|
||||||
|
|
|
@ -53,7 +53,6 @@ fn op_main_module(
|
||||||
let main_path = std::env::current_dir().unwrap().join(main_url.to_string());
|
let main_path = std::env::current_dir().unwrap().join(main_url.to_string());
|
||||||
state.check_read_blind(&main_path, "main_module")?;
|
state.check_read_blind(&main_path, "main_module")?;
|
||||||
}
|
}
|
||||||
state.check_unstable("Deno.mainModule");
|
|
||||||
Ok(JsonOp::Sync(json!(&main)))
|
Ok(JsonOp::Sync(json!(&main)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,14 +328,10 @@ delete Object.prototype.__proto__;
|
||||||
ppid: util.readOnly(ppid),
|
ppid: util.readOnly(ppid),
|
||||||
noColor: util.readOnly(noColor),
|
noColor: util.readOnly(noColor),
|
||||||
args: util.readOnly(Object.freeze(args)),
|
args: util.readOnly(Object.freeze(args)),
|
||||||
|
mainModule: util.getterOnly(opMainModule),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (unstableFlag) {
|
if (unstableFlag) {
|
||||||
Object.defineProperty(
|
|
||||||
finalDenoNs,
|
|
||||||
"mainModule",
|
|
||||||
util.getterOnly(opMainModule),
|
|
||||||
);
|
|
||||||
Object.assign(finalDenoNs, denoNsUnstable);
|
Object.assign(finalDenoNs, denoNsUnstable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1925,7 +1925,7 @@ itest!(import_meta {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(main_module {
|
itest!(main_module {
|
||||||
args: "run --quiet --unstable --allow-read --reload main_module.ts",
|
args: "run --quiet --allow-read --reload main_module.ts",
|
||||||
output: "main_module.ts.out",
|
output: "main_module.ts.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ delete Object.prototype.__proto__;
|
||||||
"PermissionStatus",
|
"PermissionStatus",
|
||||||
"hostname",
|
"hostname",
|
||||||
"ppid",
|
"ppid",
|
||||||
"mainModule",
|
|
||||||
"ftruncate",
|
"ftruncate",
|
||||||
"ftruncateSync",
|
"ftruncateSync",
|
||||||
"fdatasync",
|
"fdatasync",
|
||||||
|
|
Loading…
Reference in a new issue