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

feat(lint): add Deno.run to no-deprecated-deno-api (#18869)

This upgrade includes a warning for the deprecated "Deno.run()" API.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
Bartek Iwańczuk 2023-04-27 04:52:52 +02:00 committed by GitHub
parent a16ad526e9
commit 4192978c3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 4 deletions

4
Cargo.lock generated
View file

@ -1062,9 +1062,9 @@ dependencies = [
[[package]]
name = "deno_lint"
version = "0.44.0"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8314e893e86e7f66cf06926d684a5d8708d737a28056472c9d7d78ef1c00691b"
checksum = "3867178bfb6579aaf9ed79599d3181d134f13dfcd38fdd93cae7d53a37bece8d"
dependencies = [
"anyhow",
"deno_ast",

View file

@ -45,7 +45,7 @@ deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"]
deno_doc = "0.62.0"
deno_emit = "0.20.0"
deno_graph = "=0.48.1"
deno_lint = { version = "0.44.0", features = ["docs"] }
deno_lint = { version = "0.45.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }

View file

@ -7,6 +7,7 @@ Deno.test("complex", function () {
Deno.test("sub process with stdin", async () => {
// ensure launching deno run with stdin doesn't affect coverage
const code = "console.log('5')";
// deno-lint-ignore no-deprecated-deno-api
const p = await Deno.run({
cmd: [Deno.execPath(), "run", "-"],
stdin: "piped",
@ -25,6 +26,7 @@ Deno.test("sub process with stdin", async () => {
Deno.test("sub process with deno eval", async () => {
// ensure launching deno eval doesn't affect coverage
const code = "console.log('5')";
// deno-lint-ignore no-deprecated-deno-api
const p = await Deno.run({
cmd: [Deno.execPath(), "eval", code],
stdout: "piped",

View file

@ -1,4 +1,5 @@
Deno.test("output", async () => {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "console.log(0); console.error(1);"],
});

View file

@ -2085,6 +2085,7 @@ Deno.test({
"--header",
"Accept-Encoding: deflate, gzip",
];
// deno-lint-ignore no-deprecated-deno-api
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
const status = await proc.status();
assert(status.success);
@ -2147,6 +2148,7 @@ Deno.test({
"--header",
"Accept-Encoding: deflate, gzip",
];
// deno-lint-ignore no-deprecated-deno-api
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
const status = await proc.status();
assert(status.success);

View file

@ -11,6 +11,7 @@ Deno.test(
{ permissions: { read: true, run: false } },
function runPermissions() {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
});
@ -21,6 +22,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runSuccess() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
// freeze the array to ensure it's not modified
cmd: Object.freeze([
@ -43,6 +45,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runUrl() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
new URL(`file:///${Deno.execPath()}`),
@ -66,6 +69,7 @@ Deno.test(
async function runStdinRid0(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
stdin: 0,
@ -85,6 +89,7 @@ Deno.test(
{ permissions: { run: true, read: true } },
function runInvalidStdio() {
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stdin.
@ -92,6 +97,7 @@ Deno.test(
})
);
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stdout.
@ -99,6 +105,7 @@ Deno.test(
})
);
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stderr.
@ -111,6 +118,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runCommandFailedWithCode() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "Deno.exit(41 + 1)"],
});
@ -127,6 +135,7 @@ Deno.test(
permissions: { run: true, read: true },
},
async function runCommandFailedWithSignal() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -150,6 +159,7 @@ Deno.test(
Deno.test({ permissions: { run: true } }, function runNotFound() {
let error;
try {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({ cmd: ["this file hopefully doesn't exist"] });
} catch (e) {
error = e;
@ -181,6 +191,7 @@ tryExit();
`;
Deno.writeFileSync(`${cwd}/${programFile}`, enc.encode(program));
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cwd,
cmd: [Deno.execPath(), "run", "--allow-read", programFile],
@ -204,6 +215,7 @@ Deno.test(
async function runStdinPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -235,6 +247,7 @@ Deno.test(
async function runStdoutPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -271,6 +284,7 @@ Deno.test(
async function runStderrPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -305,6 +319,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runOutput() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -325,6 +340,7 @@ Deno.test(
async function runStderrOutput(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -350,6 +366,7 @@ Deno.test(
write: true,
});
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -382,6 +399,7 @@ Deno.test(
await Deno.writeFile(fileName, encoder.encode("hello"));
const file = await Deno.open(fileName);
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -401,6 +419,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runEnv() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -423,6 +442,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runClose() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -446,6 +466,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runKillAfterStatus() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", 'console.log("hello")'],
});
@ -502,6 +523,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function killSuccess() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
});
@ -525,6 +547,7 @@ Deno.test(
);
Deno.test({ permissions: { run: true, read: true } }, function killFailed() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
});
@ -542,6 +565,7 @@ Deno.test({ permissions: { run: true, read: true } }, function killFailed() {
Deno.test(
{ permissions: { run: true, read: true, env: true } },
async function clearEnv(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
@ -574,6 +598,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function uid(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
"id",
@ -587,6 +612,7 @@ Deno.test(
if (currentUid !== "0") {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [
"echo",
@ -605,6 +631,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function gid(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
"id",
@ -618,6 +645,7 @@ Deno.test(
if (currentGid !== "0") {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [
"echo",
@ -636,6 +664,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function non_existent_cwd(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),

@ -1 +1 @@
Subproject commit fef5eaa2e364db431cfbf8089afdd81f71fd46d2
Subproject commit ee59830ca23fd0aa423a3905005835c586e73e77