import chokidar from "chokidar"; import { install } from "./install.js"; import express from "express"; import livereload from "livereload"; import fs from "node:fs"; install(process.argv[2]); // launch express server with livereload const liveReloadServer = livereload.createServer(); const app = express({ root: "./dist", index: "index.html", }); app.get("*", (req, res) => { // Build the path of the file using the URL pathname of the request. if (req.url.indexOf("font.woff2") > 0) { res.sendFile("sketchybar-app-font.woff2", {root: "./dist"}); return; } res.send(getPreviewHTML()); }); const PORT = 3003; app.listen(PORT, () => { console.log("listening on port ", PORT); }); chokidar.watch(["./mappings", "./svgs"]).on("change", (event, path) => { install(process.argv[2], false); liveReloadServer.refresh("/"); }); function getPreviewHTML() { const iconMap = fs .readdirSync("./mappings") .map((file) => file.replace(".svg", "")); return ` Sketchybar App Font Preview

Sketchybar App Font Preview

${iconMap .map( (iconName) => `
${iconName}${iconName}
` ) .join("\n")}

`; }