Skip to content

Commit 195b17a

Browse files
authored
BREAKING(types): soft-remove Deno.run() (#25403)
Towards #22079
1 parent c32d692 commit 195b17a

9 files changed

Lines changed: 58 additions & 368 deletions

File tree

‎cli/tsc/dts/lib.deno.ns.d.ts‎

Lines changed: 3 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -3925,175 +3925,6 @@ declare namespace Deno {
39253925
options?: { recursive: boolean },
39263926
): FsWatcher;
39273927

3928-
/**
3929-
* Options which can be used with {@linkcode Deno.run}.
3930-
*
3931-
* @deprecated This will be removed in Deno 2.0. See the
3932-
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
3933-
* for migration instructions.
3934-
*
3935-
* @category Subprocess */
3936-
export interface RunOptions {
3937-
/** Arguments to pass.
3938-
*
3939-
* _Note_: the first element needs to be a path to the executable that is
3940-
* being run. */
3941-
cmd: readonly string[] | [string | URL, ...string[]];
3942-
/** The current working directory that should be used when running the
3943-
* sub-process. */
3944-
cwd?: string;
3945-
/** Any environment variables to be set when running the sub-process. */
3946-
env?: Record<string, string>;
3947-
/** By default subprocess inherits `stdout` of parent process. To change
3948-
* this this option can be set to a resource ID (_rid_) of an open file,
3949-
* `"inherit"`, `"piped"`, or `"null"`:
3950-
*
3951-
* - _number_: the resource ID of an open file/resource. This allows you to
3952-
* write to a file.
3953-
* - `"inherit"`: The default if unspecified. The subprocess inherits from the
3954-
* parent.
3955-
* - `"piped"`: A new pipe should be arranged to connect the parent and child
3956-
* sub-process.
3957-
* - `"null"`: This stream will be ignored. This is the equivalent of attaching
3958-
* the stream to `/dev/null`.
3959-
*/
3960-
stdout?: "inherit" | "piped" | "null" | number;
3961-
/** By default subprocess inherits `stderr` of parent process. To change
3962-
* this this option can be set to a resource ID (_rid_) of an open file,
3963-
* `"inherit"`, `"piped"`, or `"null"`:
3964-
*
3965-
* - _number_: the resource ID of an open file/resource. This allows you to
3966-
* write to a file.
3967-
* - `"inherit"`: The default if unspecified. The subprocess inherits from the
3968-
* parent.
3969-
* - `"piped"`: A new pipe should be arranged to connect the parent and child
3970-
* sub-process.
3971-
* - `"null"`: This stream will be ignored. This is the equivalent of attaching
3972-
* the stream to `/dev/null`.
3973-
*/
3974-
stderr?: "inherit" | "piped" | "null" | number;
3975-
/** By default subprocess inherits `stdin` of parent process. To change
3976-
* this this option can be set to a resource ID (_rid_) of an open file,
3977-
* `"inherit"`, `"piped"`, or `"null"`:
3978-
*
3979-
* - _number_: the resource ID of an open file/resource. This allows you to
3980-
* read from a file.
3981-
* - `"inherit"`: The default if unspecified. The subprocess inherits from the
3982-
* parent.
3983-
* - `"piped"`: A new pipe should be arranged to connect the parent and child
3984-
* sub-process.
3985-
* - `"null"`: This stream will be ignored. This is the equivalent of attaching
3986-
* the stream to `/dev/null`.
3987-
*/
3988-
stdin?: "inherit" | "piped" | "null" | number;
3989-
}
3990-
3991-
/**
3992-
* The status resolved from the `.status()` method of a
3993-
* {@linkcode Deno.Process} instance.
3994-
*
3995-
* If `success` is `true`, then `code` will be `0`, but if `success` is
3996-
* `false`, the sub-process exit code will be set in `code`.
3997-
*
3998-
* @deprecated This will be removed in Deno 2.0. See the
3999-
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
4000-
* for migration instructions.
4001-
*
4002-
* @category Subprocess */
4003-
export type ProcessStatus =
4004-
| {
4005-
success: true;
4006-
code: 0;
4007-
signal?: undefined;
4008-
}
4009-
| {
4010-
success: false;
4011-
code: number;
4012-
signal?: number;
4013-
};
4014-
4015-
/**
4016-
* Represents an instance of a sub process that is returned from
4017-
* {@linkcode Deno.run} which can be used to manage the sub-process.
4018-
*
4019-
* @deprecated This will be removed in Deno 2.0. See the
4020-
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
4021-
* for migration instructions.
4022-
*
4023-
* @category Subprocess */
4024-
export class Process<T extends RunOptions = RunOptions> {
4025-
/** The resource ID of the sub-process. */
4026-
readonly rid: number;
4027-
/** The operating system's process ID for the sub-process. */
4028-
readonly pid: number;
4029-
/** A reference to the sub-processes `stdin`, which allows interacting with
4030-
* the sub-process at a low level. */
4031-
readonly stdin: T["stdin"] extends "piped" ? Writer & Closer & {
4032-
writable: WritableStream<Uint8Array>;
4033-
}
4034-
: (Writer & Closer & { writable: WritableStream<Uint8Array> }) | null;
4035-
/** A reference to the sub-processes `stdout`, which allows interacting with
4036-
* the sub-process at a low level. */
4037-
readonly stdout: T["stdout"] extends "piped" ? Reader & Closer & {
4038-
readable: ReadableStream<Uint8Array>;
4039-
}
4040-
: (Reader & Closer & { readable: ReadableStream<Uint8Array> }) | null;
4041-
/** A reference to the sub-processes `stderr`, which allows interacting with
4042-
* the sub-process at a low level. */
4043-
readonly stderr: T["stderr"] extends "piped" ? Reader & Closer & {
4044-
readable: ReadableStream<Uint8Array>;
4045-
}
4046-
: (Reader & Closer & { readable: ReadableStream<Uint8Array> }) | null;
4047-
/** Wait for the process to exit and return its exit status.
4048-
*
4049-
* Calling this function multiple times will return the same status.
4050-
*
4051-
* The `stdin` reference to the process will be closed before waiting to
4052-
* avoid a deadlock.
4053-
*
4054-
* If `stdout` and/or `stderr` were set to `"piped"`, they must be closed
4055-
* manually before the process can exit.
4056-
*
4057-
* To run process to completion and collect output from both `stdout` and
4058-
* `stderr` use:
4059-
*
4060-
* ```ts
4061-
* const p = Deno.run({ cmd: [ "echo", "hello world" ], stderr: 'piped', stdout: 'piped' });
4062-
* const [status, stdout, stderr] = await Promise.all([
4063-
* p.status(),
4064-
* p.output(),
4065-
* p.stderrOutput()
4066-
* ]);
4067-
* p.close();
4068-
* ```
4069-
*/
4070-
status(): Promise<ProcessStatus>;
4071-
/** Buffer the stdout until EOF and return it as `Uint8Array`.
4072-
*
4073-
* You must set `stdout` to `"piped"` when creating the process.
4074-
*
4075-
* This calls `close()` on stdout after its done. */
4076-
output(): Promise<Uint8Array>;
4077-
/** Buffer the stderr until EOF and return it as `Uint8Array`.
4078-
*
4079-
* You must set `stderr` to `"piped"` when creating the process.
4080-
*
4081-
* This calls `close()` on stderr after its done. */
4082-
stderrOutput(): Promise<Uint8Array>;
4083-
/** Clean up resources associated with the sub-process instance. */
4084-
close(): void;
4085-
/** Send a signal to process.
4086-
* Default signal is `"SIGTERM"`.
4087-
*
4088-
* ```ts
4089-
* const p = Deno.run({ cmd: [ "sleep", "20" ]});
4090-
* p.kill("SIGTERM");
4091-
* p.close();
4092-
* ```
4093-
*/
4094-
kill(signo?: Signal): void;
4095-
}
4096-
40973928
/** Operating signals which can be listened for or sent to sub-processes. What
40983929
* signals and what their standard behaviors are OS dependent.
40993930
*
@@ -4175,61 +4006,6 @@ declare namespace Deno {
41754006
handler: () => void,
41764007
): void;
41774008

4178-
/**
4179-
* Spawns new subprocess. RunOptions must contain at a minimum the `opt.cmd`,
4180-
* an array of program arguments, the first of which is the binary.
4181-
*
4182-
* ```ts
4183-
* const p = Deno.run({
4184-
* cmd: ["curl", "https://example.com"],
4185-
* });
4186-
* const status = await p.status();
4187-
* ```
4188-
*
4189-
* Subprocess uses same working directory as parent process unless `opt.cwd`
4190-
* is specified.
4191-
*
4192-
* Environmental variables from parent process can be cleared using `opt.clearEnv`.
4193-
* Doesn't guarantee that only `opt.env` variables are present,
4194-
* as the OS may set environmental variables for processes.
4195-
*
4196-
* Environmental variables for subprocess can be specified using `opt.env`
4197-
* mapping.
4198-
*
4199-
* `opt.uid` sets the child process’s user ID. This translates to a setuid call
4200-
* in the child process. Failure in the setuid call will cause the spawn to fail.
4201-
*
4202-
* `opt.gid` is similar to `opt.uid`, but sets the group ID of the child process.
4203-
* This has the same semantics as the uid field.
4204-
*
4205-
* By default subprocess inherits stdio of parent process. To change
4206-
* this this, `opt.stdin`, `opt.stdout`, and `opt.stderr` can be set
4207-
* independently to a resource ID (_rid_) of an open file, `"inherit"`,
4208-
* `"piped"`, or `"null"`:
4209-
*
4210-
* - _number_: the resource ID of an open file/resource. This allows you to
4211-
* read or write to a file.
4212-
* - `"inherit"`: The default if unspecified. The subprocess inherits from the
4213-
* parent.
4214-
* - `"piped"`: A new pipe should be arranged to connect the parent and child
4215-
* sub-process.
4216-
* - `"null"`: This stream will be ignored. This is the equivalent of attaching
4217-
* the stream to `/dev/null`.
4218-
*
4219-
* Details of the spawned process are returned as an instance of
4220-
* {@linkcode Deno.Process}.
4221-
*
4222-
* Requires `allow-run` permission.
4223-
*
4224-
* @deprecated This will be soft-removed in Deno 2.0. See the
4225-
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
4226-
* for migration instructions.
4227-
*
4228-
* @tags allow-run
4229-
* @category Subprocess
4230-
*/
4231-
export function run<T extends RunOptions = RunOptions>(opt: T): Process<T>;
4232-
42334009
/** Create a child process.
42344010
*
42354011
* If any stdio options are not set to `"piped"`, accessing the corresponding
@@ -5308,11 +5084,10 @@ declare namespace Deno {
53085084
* Windows.
53095085
*
53105086
* ```ts
5311-
* const p = Deno.run({
5312-
* cmd: ["sleep", "10000"]
5313-
* });
5087+
* const command = new Deno.Command("sleep", { args: ["10000"] });
5088+
* const child = command.spawn();
53145089
*
5315-
* Deno.kill(p.pid, "SIGINT");
5090+
* Deno.kill(child.pid, "SIGINT");
53165091
* ```
53175092
*
53185093
* Requires `allow-run` permission.

‎cli/tsc/dts/lib.deno.unstable.d.ts‎

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -840,80 +840,6 @@ declare namespace Deno {
840840
present(): void;
841841
}
842842

843-
/** **UNSTABLE**: New API, yet to be vetted.
844-
*
845-
* These are unstable options which can be used with {@linkcode Deno.run}.
846-
*
847-
* @category Subprocess
848-
* @experimental
849-
*/
850-
export interface UnstableRunOptions extends RunOptions {
851-
/** If `true`, clears the environment variables before executing the
852-
* sub-process.
853-
*
854-
* @default {false} */
855-
clearEnv?: boolean;
856-
/** For POSIX systems, sets the group ID for the sub process. */
857-
gid?: number;
858-
/** For POSIX systems, sets the user ID for the sub process. */
859-
uid?: number;
860-
}
861-
862-
/** **UNSTABLE**: New API, yet to be vetted.
863-
*
864-
* Spawns new subprocess. RunOptions must contain at a minimum the `opt.cmd`,
865-
* an array of program arguments, the first of which is the binary.
866-
*
867-
* ```ts
868-
* const p = Deno.run({
869-
* cmd: ["curl", "https://example.com"],
870-
* });
871-
* const status = await p.status();
872-
* ```
873-
*
874-
* Subprocess uses same working directory as parent process unless `opt.cwd`
875-
* is specified.
876-
*
877-
* Environmental variables from parent process can be cleared using `opt.clearEnv`.
878-
* Doesn't guarantee that only `opt.env` variables are present,
879-
* as the OS may set environmental variables for processes.
880-
*
881-
* Environmental variables for subprocess can be specified using `opt.env`
882-
* mapping.
883-
*
884-
* `opt.uid` sets the child process’s user ID. This translates to a setuid call
885-
* in the child process. Failure in the setuid call will cause the spawn to fail.
886-
*
887-
* `opt.gid` is similar to `opt.uid`, but sets the group ID of the child process.
888-
* This has the same semantics as the uid field.
889-
*
890-
* By default subprocess inherits stdio of parent process. To change
891-
* this this, `opt.stdin`, `opt.stdout`, and `opt.stderr` can be set
892-
* independently to a resource ID (_rid_) of an open file, `"inherit"`,
893-
* `"piped"`, or `"null"`:
894-
*
895-
* - _number_: the resource ID of an open file/resource. This allows you to
896-
* read or write to a file.
897-
* - `"inherit"`: The default if unspecified. The subprocess inherits from the
898-
* parent.
899-
* - `"piped"`: A new pipe should be arranged to connect the parent and child
900-
* sub-process.
901-
* - `"null"`: This stream will be ignored. This is the equivalent of attaching
902-
* the stream to `/dev/null`.
903-
*
904-
* Details of the spawned process are returned as an instance of
905-
* {@linkcode Deno.Process}.
906-
*
907-
* Requires `allow-run` permission.
908-
*
909-
* @tags allow-run
910-
* @category Subprocess
911-
* @experimental
912-
*/
913-
export function run<T extends UnstableRunOptions = UnstableRunOptions>(
914-
opt: T,
915-
): Process<T>;
916-
917843
/** **UNSTABLE**: New API, yet to be vetted.
918844
*
919845
* A custom `HttpClient` for use with {@linkcode fetch} function. This is

‎runtime/js/40_process.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class Process {
130130
}
131131
}
132132

133+
// Note: This function was soft-removed in Deno 2. Its types have been removed,
134+
// but its implementation has been kept to avoid breaking changes.
133135
function run({
134136
cmd,
135137
cwd = undefined,
@@ -144,11 +146,6 @@ function run({
144146
...new SafeArrayIterator(ArrayPrototypeSlice(cmd, 1)),
145147
];
146148
}
147-
internals.warnOnDeprecatedApi(
148-
"Deno.run()",
149-
(new Error()).stack,
150-
`Use "Deno.Command()" API instead.`,
151-
);
152149
const res = opRun({
153150
cmd: ArrayPrototypeMap(cmd, String),
154151
cwd,

0 commit comments

Comments
 (0)