Skip to content

Commit 5682e6b

Browse files
authored
Copy gitignore files. (#39)
* Copy gitignore files. * Slash before replace.
1 parent 1820f7b commit 5682e6b

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ cd create-greet
7575

7676
Then you can see the `templates/default` folder where the actual template files go.
7777

78+
Note that `.gitignore` files should be named `gitignore` to avoid being ignored on publishing.
79+
7880
### 3. Build the app (TypeScript only)
7981

8082
Run `npm run build` or `yarn build` to transpile TypeScript code into JavaScript. If you chose the default template, this step is not necessary.

src/template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export async function copy(args: CopyConfig) {
8888
const templateFiles = await globby(slash(args.templateDir), { dot: true });
8989
for (const sourcePath of templateFiles) {
9090
const relativePath = path.relative(args.templateDir, sourcePath);
91-
const targetPath = format(
91+
const targetPath = slash(format(
9292
path.resolve(args.packageDir, relativePath),
9393
args.view
94-
);
94+
)).replace(/\/gitignore$/, '/.gitignore'); // https://github.com/uetchy/create-create-app/issues/38
9595
prepareDirectory(targetPath);
9696

9797
let sourceData = fs.readFileSync(sourcePath);
File renamed without changes.
File renamed without changes.

tests/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ test('create default project', async () => {
3636
expect(existsSync(`${baseDir}/create-greet/package-lock.json`)).toBeFalsy();
3737
expect(existsSync(`${baseDir}/create-greet/pnpm-lock.yaml`)).toBeTruthy();
3838

39+
const newGitignore = readFileSync(
40+
`${baseDir}/create-greet/.gitignore`,
41+
'utf-8'
42+
);
43+
expect(newGitignore).toContain('node_modules/');
44+
3945
const newReadMe = readFileSync(`${baseDir}/create-greet/README.md`, 'utf-8');
4046
expect(newReadMe).toContain('# Create Greet');
4147
expect(newReadMe).toContain('- {{author}} => Awesome Doe');

0 commit comments

Comments
 (0)