Skip to content

Commit dd2392a

Browse files
fix: don't create src/ files during --mode migrate (#841)
## PR Checklist - [x] Addresses an existing open issue: fixes #749 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Passes in the root `mode` to `writeStructure` -> `createStructure` so it knows not to call `createSrc` during migration.
1 parent 5ceee52 commit dd2392a

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Diff for: src/create/createWithOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) {
1616
[
1717
"Writing structure",
1818
async () => {
19-
await writeStructure(options);
19+
await writeStructure(options, "create");
2020
},
2121
],
2222
[

Diff for: src/migrate/migrateWithOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function migrateWithOptions({
1919
[
2020
"Writing structure",
2121
async () => {
22-
await writeStructure(options);
22+
await writeStructure(options, "migrate");
2323
},
2424
],
2525
[

Diff for: src/steps/writing/creation/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Mode } from "../../../bin/mode.js";
12
import { Options } from "../../../shared/types.js";
23
import { Structure } from "../types.js";
34
import { createDotGitHub } from "./dotGitHub/index.js";
@@ -6,12 +7,15 @@ import { createDotVSCode } from "./dotVSCode.js";
67
import { createRootFiles } from "./rootFiles.js";
78
import { createSrc } from "./src.js";
89

9-
export async function createStructure(options: Options): Promise<Structure> {
10+
export async function createStructure(
11+
options: Options,
12+
mode: Mode,
13+
): Promise<Structure> {
1014
return {
1115
".github": await createDotGitHub(options),
1216
".husky": createDotHusky(),
1317
".vscode": await createDotVSCode(options),
14-
src: await createSrc(options),
18+
...(mode !== "migrate" && { src: await createSrc(options) }),
1519
...(await createRootFiles(options)),
1620
};
1721
}

Diff for: src/steps/writing/writeStructure.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { $ } from "execa";
22

3+
import { Mode } from "../../bin/mode.js";
34
import { Options } from "../../shared/types.js";
45
import { createStructure } from "./creation/index.js";
56
import { writeStructureWorker } from "./writeStructureWorker.js";
67

7-
export async function writeStructure(options: Options) {
8-
await writeStructureWorker(await createStructure(options), ".");
8+
export async function writeStructure(options: Options, mode: Mode) {
9+
await writeStructureWorker(await createStructure(options, mode), ".");
910

1011
// https://github.com/JoshuaKGoldberg/create-typescript-app/issues/718
1112
await $`chmod ug+x .husky/pre-commit`;

0 commit comments

Comments
 (0)