Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Mar 15, 2022
1 parent b63bc1e commit 17ba6d8
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions scripts/draft-blog-post.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import fs from "node:fs";
import path from "node:path";
import minimist from "minimist";
import rimraf from "rimraf";
import createEsmUtils from "esm-utils";
import {
Expand All @@ -13,15 +12,6 @@ import {
printEntries,
} from "./utils/changelog.mjs";

const options = minimist(process.argv.slice(2), {
boolean: ["print-truncate"],
default: {
["print-truncate"]: true,
},
});

const shouldPrintTruncate = options["print-truncate"];

const { __dirname, require } = createEsmUtils(import.meta);
const blogDir = path.join(__dirname, "../website/blog");
const introTemplateFile = path.join(
Expand Down Expand Up @@ -79,12 +69,17 @@ for (const dir of changelogUnreleasedDirs) {

rimraf.sync(postGlob);

const introFileData = fs.readFileSync(introFile, "utf8").trim();

const TRUNCATE_COMMENT = "<!--truncate-->";
const shouldPrintTruncate = introFileData.includes(TRUNCATE_COMMENT);

fs.writeFileSync(
postFile,
replaceVersions(
[
fs.readFileSync(introFile, "utf8").trim(),
shouldPrintTruncate ? "<!--truncate-->" : "",
introFileData,
shouldPrintTruncate ? TRUNCATE_COMMENT : "",
...printEntriesWithTitle({
title: "Highlights",
filter: (entry) => entry.section === "highlight",
Expand Down

0 comments on commit 17ba6d8

Please sign in to comment.