mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
fix: Deno.run
- do not modify user provided cmd
array (#14109)
This commit is contained in:
parent
84b1acf8ba
commit
4691bde429
2
cli/dts/lib.deno.ns.d.ts
vendored
2
cli/dts/lib.deno.ns.d.ts
vendored
@ -2398,7 +2398,7 @@ declare namespace Deno {
|
||||
export interface RunOptions {
|
||||
/** Arguments to pass. Note, the first element needs to be a path to the
|
||||
* binary */
|
||||
cmd: string[] | [URL, ...string[]];
|
||||
cmd: readonly string[] | [URL, ...string[]];
|
||||
cwd?: string;
|
||||
env?: {
|
||||
[key: string]: string;
|
||||
|
@ -21,7 +21,12 @@ Deno.test(
|
||||
{ permissions: { run: true, read: true } },
|
||||
async function runSuccess() {
|
||||
const p = Deno.run({
|
||||
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
||||
// freeze the array to ensure it's not modified
|
||||
cmd: Object.freeze([
|
||||
Deno.execPath(),
|
||||
"eval",
|
||||
"console.log('hello world')",
|
||||
]),
|
||||
stdout: "piped",
|
||||
stderr: "null",
|
||||
});
|
||||
|
@ -9,6 +9,7 @@
|
||||
const { assert } = window.__bootstrap.infra;
|
||||
const {
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypeSlice,
|
||||
TypeError,
|
||||
isNaN,
|
||||
ObjectEntries,
|
||||
@ -110,7 +111,7 @@
|
||||
stdin = "inherit",
|
||||
}) {
|
||||
if (cmd[0] != null) {
|
||||
cmd[0] = pathFromURL(cmd[0]);
|
||||
cmd = [pathFromURL(cmd[0]), ...ArrayPrototypeSlice(cmd, 1)];
|
||||
}
|
||||
const res = opRun({
|
||||
cmd: ArrayPrototypeMap(cmd, String),
|
||||
|
Loading…
Reference in New Issue
Block a user