Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(tools/respec2html): prevent crash on --version flag (speced#4420)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Apr 5, 2023
1 parent 4127e9a commit 7d0fb44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/respec2html.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env node
import { readFile, writeFile } from "fs/promises";
import colors from "colors";
import { fileURLToPath } from "url";
import finalhandler from "finalhandler";
import http from "http";
import { marked } from "marked";
import path from "path";
import sade from "sade";
import serveStatic from "serve-static";
import { toHTML } from "./respecDocWriter.js";
import { writeFile } from "fs/promises";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

class Renderer extends marked.Renderer {
strong(text) {
Expand Down Expand Up @@ -204,8 +207,9 @@ cli.action(async (source, destination, opts) => {
});

// https://github.com/lukeed/sade/issues/28#issuecomment-516104013
cli._version = () => {
const { version } = require("../package.json");
cli._version = async () => {
const packageJson = path.join(__dirname, "..", "package.json");
const { version } = JSON.parse(await readFile(packageJson));
console.log(version);
};

Expand Down

0 comments on commit 7d0fb44

Please sign in to comment.