Skip to content

Commit

Permalink
Merge pull request #662 from load1n9/deno2
Browse files Browse the repository at this point in the history
chore: update for deno 2
  • Loading branch information
oscarotero authored Sep 9, 2024
2 parents dbf5477 + 5169e7b commit 6be7c48
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 29 deletions.
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/changelog@v2.5.3/bin.ts",
"update-deps": "deno run -A --quiet 'https://deno.land/x/nudd@v0.2.8/cli.ts' update deps/*.ts deno.json"
"changelog": "deno --allow-read --allow-write https://deno.land/x/changelog@v2.5.3/bin.ts",
"update-deps": "deno -A --quiet 'https://deno.land/x/nudd@v0.2.8/cli.ts' update deps/*.ts deno.json"
},
"imports": {
"lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/cms@0.5.10/"
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

0 comments on commit 6be7c48

Please sign in to comment.