Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update for deno 2 #662

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ title: Welcome to my page

Build it:

```
deno run -A https://deno.land/x/lume/cli.ts
```sh
deno -A https://deno.land/x/lume/cli.ts
```

This command will compile your documents to HTML and save them into the
Expand Down
7 changes: 1 addition & 6 deletions cli/build_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ onmessage = async (event) => {
site.root(),
);

function mustReload(files: Set<string>): boolean {
if (files.has(_config)) {
return true;
}
return false;
}
const mustReload = (files: Set<string>): boolean => files.has(_config);

watcher.addEventListener("change", (event) => {
const files = event.files!;
Expand Down
8 changes: 2 additions & 6 deletions cli/cms_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ onmessage = async (event) => {
site.root(),
);

function mustReload(files: Set<string>): boolean {
if (files.has(_config) || files.has(_cms)) {
return true;
}
return false;
}
const mustReload = (files: Set<string>): boolean =>
files.has(_config) || files.has(_cms);

site.addEventListener("beforeUpdate", (ev) => {
if (mustReload(ev.files)) {
Expand Down
6 changes: 1 addition & 5 deletions core/loaders/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ const binaryFormats = new Set<string>([
]);

export default function getLoader(extension: string): Loader {
if (binaryFormats.has(extension)) {
return binaryLoader;
}

return textLoader;
return binaryFormats.has(extension) ? binaryLoader : textLoader;
}
5 changes: 3 additions & 2 deletions core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { decodeURIComponentSafe } from "./utils/path.ts";
export interface Options extends Deno.ServeOptions {
/** The root path */
root: string;
port?: number;
}

export const defaults: Options = {
Expand Down Expand Up @@ -92,10 +93,10 @@ export default class Server {
stop() {
try {
this.#server?.shutdown();
} catch (error) {
} catch (err) {
this.dispatchEvent({
type: "error",
error,
error: err as Error,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export default class FSWatcher implements Watcher {
runningCallback = false;
return watcher.close();
}
} catch (error) {
await this.dispatchEvent({ type: "error", error });
} catch (err) {
await this.dispatchEvent({ type: "error", error: err as Error });
}

runningCallback = false;
Expand Down
7 changes: 5 additions & 2 deletions core/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ export class FSWriter implements Writer {
}</gray>`,
);
return true;
} catch (error) {
log.error(`Failed to copy file: ${file.outputPath}: ${error.message}`);
} catch (error: unknown) {
log.error(
// deno-lint-ignore no-explicit-any
`Failed to copy file: ${file.outputPath}: ${(error as any).message}`,
);
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"tasks": {
"test": "TZ=Z LUME_LOGS=ERROR DENO_FUTURE=1 deno test -A",
"test:update": "deno task test -- --update",
"changelog": "deno run --allow-read --allow-write https://deno.land/x/[email protected]/bin.ts",
"update-deps": "deno run -A --quiet 'https://deno.land/x/[email protected]/cli.ts' update deps/*.ts deno.json"
"changelog": "deno --allow-read --allow-write https://deno.land/x/[email protected]/bin.ts",
"update-deps": "deno -A --quiet 'https://deno.land/x/[email protected]/cli.ts' update deps/*.ts deno.json"
},
"imports": {
"lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/[email protected]/"
Expand Down
2 changes: 1 addition & 1 deletion init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run } from "./deps/init.ts";

console.warn(
"This module is deprecated. Use `deno run -A https://lume.land/init.ts` instead.",
"This module is deprecated. Use `deno -A https://lume.land/init.ts` instead.",
);

run();
2 changes: 1 addition & 1 deletion plugins/decap_cms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const defaults: Options = {
configKey: "decap_cms",
extraHTML: "",
proxyCommand:
`deno run --allow-read --allow-net=0.0.0.0 --allow-write --allow-env ${serverUrl}`,
`deno --allow-read --allow-net=0.0.0.0 --allow-write --allow-env ${serverUrl}`,
};

/**
Expand Down