Skip to content

Commit 651b3cd

Browse files
jycouetmanuel3108
andauthored
fix(add): add /drizzle/ folder to .prettierignore (#623)
* fix(add): add `/drizzle/` folder to `.prettierignore` * add `runsAfter` --------- Co-authored-by: Manuel Serret <[email protected]>
1 parent 4a77117 commit 651b3cd

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.changeset/fair-onions-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix(add): add `/drizzle/` folder to `.prettierignore` if `prettier` is installed when adding `drizzle` addon

packages/addons/drizzle/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export default defineAddon({
7272
shortDescription: 'database orm',
7373
homepage: 'https://orm.drizzle.team',
7474
options,
75-
setup: ({ kit, unsupported, cwd, typescript }) => {
75+
setup: ({ kit, unsupported, runsAfter, cwd, typescript }) => {
76+
runsAfter('prettier');
77+
7678
const ext = typescript ? 'ts' : 'js';
7779
if (!kit) {
7880
return unsupported('Requires SvelteKit');
@@ -91,7 +93,7 @@ export default defineAddon({
9193
}
9294
}
9395
},
94-
run: ({ sv, typescript, options, kit }) => {
96+
run: ({ sv, typescript, options, kit, dependencyVersion }) => {
9597
const ext = typescript ? 'ts' : 'js';
9698

9799
sv.dependency('drizzle-orm', '^0.40.0');
@@ -180,6 +182,16 @@ export default defineAddon({
180182
return generateCode();
181183
});
182184

185+
const hasPrettier = Boolean(dependencyVersion('prettier'));
186+
if (hasPrettier) {
187+
sv.file('.prettierignore', (content) => {
188+
if (!content.includes(`/drizzle/`)) {
189+
return content.trimEnd() + '\n/drizzle/';
190+
}
191+
return content;
192+
});
193+
}
194+
183195
if (options.database === 'sqlite') {
184196
sv.file('.gitignore', (content) => {
185197
// Adds the db file to the gitignore if an ignore is present

0 commit comments

Comments
 (0)