Skip to content

Commit

Permalink
fix(vite): do not use ** in gitignore pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Oct 30, 2024
1 parent 54e76aa commit 217c7f5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`app generated files content - as-provided - my-app general application
.nuxt
.nitro
.cache
**/vite.config.*.timestamp*"
vite.config.*.timestamp*"
`;

exports[`app generated files content - as-provided - my-app general application should add the nuxt and vitest plugins 1`] = `
Expand Down Expand Up @@ -370,7 +370,7 @@ exports[`app generated files content - as-provided - myApp general application s
.nuxt
.nitro
.cache
**/vite.config.*.timestamp*"
vite.config.*.timestamp*"
`;

exports[`app generated files content - as-provided - myApp general application should add the nuxt and vitest plugins 1`] = `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stripIndents, Tree } from '@nx/devkit';

export function addViteTempFilesToGitIgnore(tree: Tree) {
let newGitIgnoreContents = `**/vite.config.*.timestamp*`;
let newGitIgnoreContents = `vite.config.*.timestamp*`;
if (tree.exists('.gitignore')) {
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
Expand Down
12 changes: 4 additions & 8 deletions packages/vite/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,14 @@ describe('@nx/vite:init', () => {

it(`should not add multiple instances of the same vite temp file glob to gitignore`, async () => {
// ARRANGE
tree.write(
'.gitignore',
'**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*'
);
tree.write('.gitignore', 'vite.config.*.timestamp*');

// ACT
await initGenerator(tree, {});

// ASSERT
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
"**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*
**/vite.config.*.timestamp*"
`);
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
`"vite.config.*.timestamp*"`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('addViteTempFilesToGitIgnore', () => {
// ASSERT
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
".idea
**/vite.config.*.timestamp*"
vite.config.*.timestamp*"
`);
});

Expand All @@ -33,7 +33,7 @@ describe('addViteTempFilesToGitIgnore', () => {
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
".idea
**/vite.config.*.timestamp*"
vite.config.*.timestamp*"
`);
});

Expand All @@ -47,7 +47,7 @@ describe('addViteTempFilesToGitIgnore', () => {

// ASSERT
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
`"**/vite.config.*.timestamp*"`
`"vite.config.*.timestamp*"`
);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stripIndents, Tree } from '@nx/devkit';

export function addViteTempFilesToGitIgnore(tree: Tree) {
let newGitIgnoreContents = `**/vite.config.*.timestamp*`;
let newGitIgnoreContents = `vite.config.*.timestamp*`;
if (tree.exists('.gitignore')) {
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
Expand Down

0 comments on commit 217c7f5

Please sign in to comment.