chore: update * pin prettier version & format code
This commit is contained in:
parent
274fe7778e
commit
45d96fae9f
18 changed files with 93 additions and 78 deletions
|
|
@ -27,7 +27,7 @@ const renderPagesToHtml = async ({
|
|||
const pageSrc = require(srcPath);
|
||||
if (!("page" in pageSrc)) {
|
||||
throw new Error(
|
||||
`page source at ${srcPath} does not export a "page" variable`
|
||||
`page source at ${srcPath} does not export a "page" variable`,
|
||||
);
|
||||
}
|
||||
let compiledHtml;
|
||||
|
|
@ -35,7 +35,7 @@ const renderPagesToHtml = async ({
|
|||
compiledHtml = renderPage(pageSrc.page());
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`failed to compile ${srcPath}: ${error.stack ?? error}`
|
||||
`failed to compile ${srcPath}: ${error.stack ?? error}`,
|
||||
);
|
||||
}
|
||||
const relPath = path.relative(pagesDir, path.dirname(srcPath));
|
||||
|
|
@ -48,7 +48,7 @@ const renderPagesToHtml = async ({
|
|||
(async () => {
|
||||
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
||||
await fs.writeFile(destPath, compiledHtml);
|
||||
})()
|
||||
})(),
|
||||
);
|
||||
}
|
||||
await Promise.all(deferred);
|
||||
|
|
@ -73,7 +73,7 @@ const copyStaticAssets = async ({
|
|||
(async () => {
|
||||
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
||||
await fs.copyFile(assetPath, destPath);
|
||||
})()
|
||||
})(),
|
||||
);
|
||||
}
|
||||
await Promise.all(deferred);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const injectLiveReloadScript = (htmlContents: string, port: number): string =>
|
|||
};
|
||||
</script>
|
||||
</html>
|
||||
`
|
||||
`,
|
||||
);
|
||||
|
||||
const guessMimeType = (ext: string): string => {
|
||||
|
|
@ -126,7 +126,7 @@ const portFromServer = (server: Pick<net.Server, "address">): number => {
|
|||
}
|
||||
if (typeof addrInfo === "string") {
|
||||
throw new Error(
|
||||
`server address is a string (this should never happen!)`
|
||||
`server address is a string (this should never happen!)`,
|
||||
);
|
||||
}
|
||||
return addrInfo.port;
|
||||
|
|
@ -187,7 +187,7 @@ const startHttpServer = async (publicDir: string): Promise<http.Server> => {
|
|||
};
|
||||
|
||||
const startWebSocketServer = async (
|
||||
httpServer: http.Server
|
||||
httpServer: http.Server,
|
||||
): Promise<import("ws").Server | undefined> => {
|
||||
// Attempt to load the ws module, aborting if it isn't available.
|
||||
let ws;
|
||||
|
|
@ -209,7 +209,7 @@ const startWebSocketServer = async (
|
|||
|
||||
const watchFolders = async (
|
||||
folders: string[],
|
||||
listener: (eventType: "update" | "remove", fileName: string) => void
|
||||
listener: (eventType: "update" | "remove", fileName: string) => void,
|
||||
): Promise<void> => {
|
||||
// Try to load node-watch, falling back to fs watch if node-watch isn't
|
||||
// available.
|
||||
|
|
@ -223,7 +223,7 @@ const watchFolders = async (
|
|||
}
|
||||
console.warn(
|
||||
`'node-watch' module not found, falling back to fs.watch (may ` +
|
||||
`result in file watch issues on some OSes)`
|
||||
`result in file watch issues on some OSes)`,
|
||||
);
|
||||
}
|
||||
// NOTE: fs.watch has significant cross-platform issues, including
|
||||
|
|
@ -279,7 +279,7 @@ const devCommand: Command = {
|
|||
const httpServer = await startHttpServer(outDir);
|
||||
const wsServer = await startWebSocketServer(httpServer);
|
||||
const watchedFolders = config.watch.filter((filePath) =>
|
||||
existsSync(filePath)
|
||||
existsSync(filePath),
|
||||
);
|
||||
await watchFolders(watchedFolders, async (event, filePath) => {
|
||||
console.log(`${filePath}:${event} triggering rebuild...`);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ interface Options {
|
|||
}
|
||||
|
||||
const parseArgs = (
|
||||
args: string[]
|
||||
args: string[],
|
||||
): { options: Options; commandName?: string; commandArgs: string[] } => {
|
||||
const options: Options = {
|
||||
showHelp: false,
|
||||
|
|
@ -46,7 +46,7 @@ const parseArgs = (
|
|||
if (moduleName == null) {
|
||||
throw new UsageError(
|
||||
`-r requires a valid module name`,
|
||||
globalHelpText
|
||||
globalHelpText,
|
||||
);
|
||||
}
|
||||
options.require.push(moduleName);
|
||||
|
|
@ -84,7 +84,7 @@ const _main = async (args: string[]): Promise<void> => {
|
|||
default:
|
||||
throw new UsageError(
|
||||
`unknown command ${commandName}`,
|
||||
globalHelpText
|
||||
globalHelpText,
|
||||
);
|
||||
}
|
||||
// NOTE: Should this just delegate to the command?
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export interface Component<P extends object = {}> {
|
|||
(
|
||||
props: P & {
|
||||
children?: Element[];
|
||||
}
|
||||
},
|
||||
): HTMLElement;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export function createElement(
|
|||
typeof value !== "boolean"
|
||||
) {
|
||||
console.warn(
|
||||
`non-primitive attribute ${key} = ${JSON.stringify(value)}`
|
||||
`non-primitive attribute ${key} = ${JSON.stringify(value)}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ const startTag = (elem: HTMLElement): string => {
|
|||
output += ` ${normalizedAttrName}=""`;
|
||||
} else {
|
||||
output += ` ${normalizedAttrName}="${escapeAttr(
|
||||
attrValue.toString()
|
||||
attrValue.toString(),
|
||||
)}"`;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,13 +94,13 @@ export const renderPage = (rootElem: Element): string => {
|
|||
if (typeof rootElem !== "object" || !("tag" in rootElem)) {
|
||||
throw new Error(
|
||||
`root page element must be a valid HTMLElement, got ${JSON.stringify(
|
||||
rootElem
|
||||
)}`
|
||||
rootElem,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
if (rootElem.tag.toLowerCase() !== "html") {
|
||||
throw new Error(
|
||||
`attempted to render page with non-HTML root element ${rootElem.tag}`
|
||||
`attempted to render page with non-HTML root element ${rootElem.tag}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export { decacheModule } from "./decache-module";
|
|||
* @return Generator that yields the files found while walking the directory.
|
||||
*/
|
||||
export const walkDir = async function* (
|
||||
dirPath: string
|
||||
dirPath: string,
|
||||
): AsyncGenerator<string> {
|
||||
const dirEnts = await fs.readdir(dirPath, { withFileTypes: true });
|
||||
for (const dirEnt of dirEnts) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue