From b90855835ba4b8842888077a4f7066fffa5f0d85 Mon Sep 17 00:00:00 2001 From: Johannes Obermair Date: Thu, 21 Dec 2023 14:49:46 +0100 Subject: [PATCH] @comet/create-app: Fix removing create-app/ entries from lint-staged.config.js Lines were never removed because the placeholder doesn't appear in the config file. Fix by moving code from `replacePlaceholder` to `cleanupWorkingDirectory` (where it actually belongs). --- create-app/src/util/cleanupWorkingDirectory.ts | 11 +++++++++++ create-app/src/util/replacePlaceholder.ts | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/create-app/src/util/cleanupWorkingDirectory.ts b/create-app/src/util/cleanupWorkingDirectory.ts index 20b78572b..acca95f54 100644 --- a/create-app/src/util/cleanupWorkingDirectory.ts +++ b/create-app/src/util/cleanupWorkingDirectory.ts @@ -1,5 +1,16 @@ +import fs from "fs"; + import { deleteFilesAndFolders } from "./deleteFilesAndFolders"; export function cleanupWorkingDirectory(verbose: boolean) { deleteFilesAndFolders(["create-app", ".git", ".github", "LICENSE"], verbose); + + const lintStagedConfigFile = fs.readFileSync("lint-staged.config.js", "utf8").toString(); + fs.writeFileSync( + "lint-staged.config.js", + lintStagedConfigFile + .split("\n") + .filter((line) => !line.includes("create-app")) + .join("\n"), + ); } diff --git a/create-app/src/util/replacePlaceholder.ts b/create-app/src/util/replacePlaceholder.ts index bb1f434af..74daba479 100644 --- a/create-app/src/util/replacePlaceholder.ts +++ b/create-app/src/util/replacePlaceholder.ts @@ -19,7 +19,6 @@ export function replacePlaceholder(projectName: string, verbose: boolean): void if (placeholder.test(contents)) { if (file.endsWith("intl-update.sh")) fs.writeFileSync(file, contents.replaceAll("lang/starter-lang", `lang/${projectName}-lang`)); - else if (file.endsWith("lint-staged.config.js")) fs.writeFileSync(file, contents.replaceAll(/"create.*lint:tsc",\n/gs, "")); else fs.writeFileSync(file, contents.replaceAll(placeholder, projectName)); changedFiles++; if (verbose) {