Skip to content

Commit

Permalink
fix: check if readme.md exists to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
juliamertz committed Oct 3, 2023
1 parent 054082a commit 8c8d153
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/utils/update-readme-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import process from "node:process";
import { type UserOptions } from "../config.js";

export const updateReadmeVersion = (version: string, flags?: UserOptions) => {
const readme = fs
.readFileSync(process.cwd() + "/readme.md", "utf8")
.toString();
const readmePath = process.cwd() + "/readme.md";
if (!fs.existsSync(readmePath)) return;

const readme = fs.readFileSync(readmePath, "utf8").toString();

const t = flags?.template ? ` -t ${flags.template}` : "";
const o = flags?.output ? ` -o ${flags.output}` : "";
Expand Down Expand Up @@ -33,5 +34,5 @@ _Generated by [@rose-pine/build@${version}](https://github.com/rose-pine/build)_
? readme.replace(searchFor, replaceWith)
: readme + `\n${replaceWith}`;

fs.writeFileSync(process.cwd() + "/readme.md", readmeWithVersion, "utf8");
fs.writeFileSync(readmePath, readmeWithVersion, "utf8");
};

0 comments on commit 8c8d153

Please sign in to comment.