Skip to content

fix(add): add /drizzle/ folder to .prettierignore #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-onions-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix(add): add `/drizzle/` folder to `.prettierignore` if `prettier` is installed when adding `drizzle` addon
16 changes: 14 additions & 2 deletions packages/addons/drizzle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export default defineAddon({
shortDescription: 'database orm',
homepage: 'https://orm.drizzle.team',
options,
setup: ({ kit, unsupported, cwd, typescript }) => {
setup: ({ kit, unsupported, runsAfter, cwd, typescript }) => {
runsAfter('prettier');

const ext = typescript ? 'ts' : 'js';
if (!kit) {
return unsupported('Requires SvelteKit');
Expand All @@ -91,7 +93,7 @@ export default defineAddon({
}
}
},
run: ({ sv, typescript, options, kit }) => {
run: ({ sv, typescript, options, kit, dependencyVersion }) => {
const ext = typescript ? 'ts' : 'js';

sv.dependency('drizzle-orm', '^0.40.0');
Expand Down Expand Up @@ -180,6 +182,16 @@ export default defineAddon({
return generateCode();
});

const hasPrettier = Boolean(dependencyVersion('prettier'));
if (hasPrettier) {
sv.file('.prettierignore', (content) => {
if (!content.includes(`/drizzle/`)) {
return content.trimEnd() + '\n/drizzle/';
}
return content;
});
}

if (options.database === 'sqlite') {
sv.file('.gitignore', (content) => {
// Adds the db file to the gitignore if an ignore is present
Expand Down