Format file outputs in postinstall of addon-test

This commit is contained in:
Valentin Palkovic 2025-01-10 14:34:57 +01:00
parent d099241c48
commit a6be1e6bfa

View File

@ -6,6 +6,7 @@ import { traverse } from 'storybook/internal/babel';
import { import {
JsPackageManagerFactory, JsPackageManagerFactory,
extractProperFrameworkName, extractProperFrameworkName,
formatFileContent,
loadAllPresets, loadAllPresets,
loadMainConfig, loadMainConfig,
serverResolve, serverResolve,
@ -461,7 +462,9 @@ export default async function postInstall(options: PostinstallOptions) {
await writeFile( await writeFile(
browserWorkspaceFile, browserWorkspaceFile,
dedent` await formatFileContent(
browserWorkspaceFile,
dedent`
import { defineWorkspace } from 'vitest/config'; import { defineWorkspace } from 'vitest/config';
import { storybookTest } from '@storybook/experimental-addon-test/vitest-plugin';${vitestInfo.frameworkPluginImport} import { storybookTest } from '@storybook/experimental-addon-test/vitest-plugin';${vitestInfo.frameworkPluginImport}
import path from 'node:path'; import path from 'node:path';
@ -489,6 +492,7 @@ export default async function postInstall(options: PostinstallOptions) {
}, },
]); ]);
`.replace(/\s+extends: '',/, '') `.replace(/\s+extends: '',/, '')
)
); );
} else { } else {
// If there's no existing Vitest/Vite config, we create a new Vitest config file. // If there's no existing Vitest/Vite config, we create a new Vitest config file.