Skip to content
4 changes: 2 additions & 2 deletions packages/adders/eslint/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const adder = defineAdderConfig({
name: 'eslint-config-prettier',
version: '^9.1.0',
dev: true,
condition: ({ prettier }) => prettier
condition: ({ isResolvable }) => isResolvable('prettier')
}
],
files: [
Expand Down Expand Up @@ -141,7 +141,7 @@ export const adder = defineAdderConfig({
{
name: () => 'eslint.config.js',
contentType: 'script',
condition: ({ prettier }) => prettier,
condition: ({ isResolvable }) => isResolvable('prettier'),
content: addEslintConfigPrettier
}
]
Expand Down
4 changes: 2 additions & 2 deletions packages/adders/tailwindcss/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const adder = defineAdderConfig({
name: 'prettier-plugin-tailwindcss',
version: '^0.6.5',
dev: true,
condition: ({ prettier }) => prettier
condition: ({ isResolvable }) => isResolvable('prettier')
}
],
files: [
Expand Down Expand Up @@ -134,7 +134,7 @@ export const adder = defineAdderConfig({

if (!plugins.includes(PLUGIN_NAME)) plugins.push(PLUGIN_NAME);
},
condition: ({ prettier }) => prettier
condition: ({ isResolvable }) => isResolvable('prettier')
}
]
});
6 changes: 5 additions & 1 deletion packages/cli/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ export async function runAddCommand(options: Options, adders: string[]): Promise

// format modified/created files with prettier (if available)
const workspace = createWorkspace(options.cwd);
if (filesToFormat.length > 0 && depsStatus === 'installed' && workspace.prettier) {
if (
filesToFormat.length > 0 &&
depsStatus === 'installed' &&
workspace.isResolvable('prettier')
) {
const { start, stop } = p.spinner();
start('Formatting modified files');
try {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/files/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Workspace<Args extends OptionDefinition> = {
options: OptionValues<Args>;
cwd: string;
dependencies: Record<string, string>;
prettier: boolean;
isResolvable: (module: string) => boolean;
typescript: boolean;
kit: { libDirectory: string; routesDirectory: string } | undefined;
packageManager: AgentName;
Expand All @@ -24,7 +24,7 @@ export function createEmptyWorkspace<Args extends OptionDefinition>() {
return {
options: {},
cwd: '',
prettier: false,
isResolvable: (_module) => false,
typescript: false,
kit: undefined
} as Workspace<Args>;
Expand All @@ -48,7 +48,7 @@ export function createWorkspace<Args extends OptionDefinition>(cwd: string): Wor

workspace.dependencies = { ...packageJson.devDependencies, ...packageJson.dependencies };
workspace.typescript = usesTypescript;
workspace.prettier = Boolean(resolve.from(cwd, 'prettier', true));
workspace.isResolvable = (module: string) => Boolean(resolve.from(workspace.cwd, module, true));
workspace.packageManager = detectPackageManager(cwd);
if ('@sveltejs/kit' in workspace.dependencies) workspace.kit = parseKitOptions(workspace);
for (const [key, value] of Object.entries(workspace.dependencies)) {
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.