Skip to content

Commit

Permalink
@comet/create-app: Fix removing create-app/ entries from lint-staged.…
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
johnnyomair committed Dec 21, 2023
1 parent e10e9d2 commit b908558
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 11 additions & 0 deletions create-app/src/util/cleanupWorkingDirectory.ts
Original file line number Diff line number Diff line change
@@ -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"),
);
}
1 change: 0 additions & 1 deletion create-app/src/util/replacePlaceholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b908558

Please sign in to comment.