Skip to content

Commit 4ad9d2e

Browse files
authored
Refactor dev script to use async/await for better readability and error handling; update import of Octokit to CommonJS format in publish script; modify generateUid function to import nanoid as default. (#360)
1 parent b35ed1d commit 4ad9d2e

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

apps/obsidian/scripts/dev.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ const dev = () => {
99
return new Promise<number>((resolve) => {
1010
compile({
1111
opts: args,
12-
builder: (opts: esbuild.BuildOptions) =>
13-
esbuild.context(opts).then((esb) => {
14-
esb.watch();
15-
// Cleanup on process termination
16-
const cleanup = () => {
17-
esb.dispose();
18-
resolve(0);
19-
};
20-
process.on('SIGINT', cleanup);
21-
process.on('SIGTERM', cleanup);
22-
return esb;
23-
}),
12+
builder: async (opts: esbuild.BuildOptions) => {
13+
const esb = await esbuild.context(opts);
14+
esb.watch();
15+
// Cleanup on process termination
16+
const cleanup = () => {
17+
esb.dispose();
18+
resolve(0);
19+
};
20+
process.on("SIGINT", cleanup);
21+
process.on("SIGTERM", cleanup);
22+
},
2423
});
2524
process.on("exit", resolve);
2625
});

apps/obsidian/scripts/publish.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import fs from "fs";
33
import path from "path";
44
import { exec } from "child_process";
55
import util from "util";
6-
import { Octokit } from "@octokit/core";
6+
// https://linear.app/discourse-graphs/issue/ENG-766/upgrade-all-commonjs-to-esm
7+
// TODO: Change to apps/obsidian to ESM
8+
// import { Octokit } from "@octokit/core";
9+
const { Octokit } = require("@octokit/core");
710
import os from "os";
811

912
dotenv.config();

apps/obsidian/src/utils/generateUid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nanoid } from "nanoid";
1+
import nanoid from "nanoid";
22

33
const generateUid = (prefix = "dg") => {
44
return `${prefix}_${nanoid()}`;

0 commit comments

Comments
 (0)