Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardtke committed Oct 17, 2024
1 parent 28b7a6a commit ef82742
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 32 deletions.
19 changes: 9 additions & 10 deletions dev/generate-coverage-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ try {
// ignore
}

const coverage = Deno.run({
cmd: ["deno", "coverage", "--unstable", SourceDir, "--lcov"],
const coverage = new Deno.Command(Deno.execPath(), {
args: ["coverage", "--unstable", SourceDir, "--lcov"],
stdout: "piped",
});
const output = await coverage.output();
const coverageStatus = await coverage.status();
if (coverageStatus.success && coverageStatus.code === 0) {
const {stdout, success, code} = await coverage.output();
if (success && code.code === 0) {
const tmpFile = await Deno.makeTempFile({
suffix: ".lcov",
});
await Deno.writeFileSync(tmpFile, output);
await Deno.writeFileSync(tmpFile, stdout);
console.log(`Written ${tmpFile}`);
const htmlStatus = await Deno.run({
cmd: ["genhtml", "-o", OutputDir, tmpFile],
}).status();
if (htmlStatus.success && htmlStatus.code === 0) {
const {success, code} = (await new Deno.Command("genhtml", {
args: ["-o", OutputDir, tmpFile],
}).output());
if (success && code === 0) {
await Deno.remove(tmpFile);
console.log(`Generated ${OutputDir}`);
Deno.exit(0);
Expand Down
6 changes: 3 additions & 3 deletions dev/intellij-deno.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This script is a workaround to allow using IntelliJ Run Configurations to execute "deno task" commands.
// It is required because IntelliJ does not allow the "File" argument to be empty.
const p = Deno.run({
cmd: ["deno", ...Deno.args],
const p = new Deno.Command(Deno.execPath(), {
args: Deno.args,
});
await p.status();
await p.spawn().status;
18 changes: 9 additions & 9 deletions dev/internal/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export function call(
cwd?: string,
...cmd: (string | undefined)[]
): ProcessLike {
let p: Deno.Process;
let p: Deno.ChildProcess;
return {
close() {
p && p.close();
p && p.kill();
},
// deno-lint-ignore require-await
async run() {
Expand All @@ -26,29 +26,29 @@ export function callAndWait(
cwd?: string,
...cmd: (string | undefined)[]
): ProcessLike {
let p: Deno.Process;
let p: Deno.ChildProcess;
return {
close() {
p && p.close();
p && p.kill();
},
async run() {
p = process(cwd, ...cmd)();
await p.status();
await p.status;
},
};
}

function process(
cwd?: string,
...cmd: (string | undefined)[]
): () => Deno.Process {
): () => Deno.ChildProcess {
return () => {
const actualCmd = cmd.filter((c) => Boolean(c)) as string[];
try {
return Deno.run({
return new Deno.Command(actualCmd[0], {
...cwd ? { cwd: path.resolve(Deno.cwd(), cwd) } : {},
cmd: actualCmd,
});
args: actualCmd.slice(1),
}).spawn();
} catch (e) {
console.error(`Could not execute ${actualCmd.join(" ")}`);
throw e;
Expand Down
10 changes: 5 additions & 5 deletions dev/write-build-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const PATH = "out/server.js";
const SEARCH_STRING = `globalThis["BUILD_INFO"]`;

async function execute(cmd: string[], fallback?: string): Promise<string | undefined> {
const p = Deno.run({
cmd,
const p = new Deno.Command(cmd[0], {
args: cmd.slice(1),
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
if (!status.success) {
const { success, stdout } = await p.output();
if (!success) {
return fallback;
}
return new TextDecoder().decode(await p.output()).trim();
return new TextDecoder().decode(stdout).trim();
}

const tag = await execute(["git", "describe", "--tags"]);
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/recipe.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export class RecipeController {
return renderTemplate(RecipeEditTemplate({ recipe }));
}

async postEdit(id: number, data: Recipe, thumbnail: File | undefined, shouldDeleteThumbnail: boolean) {
// FIXME: use _data
async postEdit(id: number, _data: Recipe, thumbnail: File | undefined, shouldDeleteThumbnail: boolean) {
const recipe = this.recipeService.find(
id,
true,
Expand Down
1 change: 0 additions & 1 deletion src/data/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class PaginationBuilder<T> {
}
}

// deno-lint-ignore no-undef
export class Pagination<T> implements Iterable<T> {
// noinspection JSUnusedGlobalSymbols
public constructor(
Expand Down
1 change: 0 additions & 1 deletion src/data/parse/schema-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface ParseHtmlToSchema {
findFirstRecipe(): SchemaRecipe | null;
}

// deno-lint-ignore no-undef
export class SchemaParser implements ParseHtmlToSchema {
constructor(private readonly html: string) {
this.html = html;
Expand Down
3 changes: 1 addition & 2 deletions tests/data/parse/import/import-recipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { importRecipes } from "../../../../src/data/parse/import/import-recipe.t
import { ParseHtmlToSchema } from "../../../../src/data/parse/schema-parser.ts";
import { FetchFn } from "../../../../src/data/util/fetch.ts";
import { withTemp } from "../../../_internal/with-temp.function.ts";
import TestContext = Deno.TestContext;

Deno.test("importRecipes", async (t) => {
let fetchCalls: { url: string; userAgent: string }[] = [];
Expand Down Expand Up @@ -42,7 +41,7 @@ Deno.test("importRecipes", async (t) => {
}
};

async function simpleTest(t: TestContext, given: unknown, then: unknown, schemaField: string, recipeField: string): Promise<void> {
async function simpleTest(t: Deno.TestContext, given: unknown, then: unknown, schemaField: string, recipeField: string): Promise<void> {
beforeEach();
await t.step(
`Given ${JSON.stringify(given)} Then Recipe#${recipeField}=${JSON.stringify(then)}`,
Expand Down

1 comment on commit ef82742

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on ef82742 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

Your deployment uses decorators. The default for 'experimentalDecorators' will be changing to 'false'. In the meantime, please explicitly set the 'experimentalDecorators' compiler option. For more information, see https://deno.com/deploy/changelog#es-decorators-are-enabled-on-deno-deploy-replacing-experimental-ts-decorators

Please sign in to comment.