fix: windows build issue and add prettier

This commit is contained in:
mingholy.lmh 2026-02-03 10:16:51 +08:00
parent a5a6bddc31
commit 8d8449079d
2 changed files with 16 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { build } from 'esbuild';
import { buildConfig } from './esbuild.config.mjs';
import prettier from 'prettier';
const assetsDir = dirname(fileURLToPath(import.meta.url));
const srcDir = join(assetsDir, 'src');
@ -83,6 +84,15 @@ const templateModule = `/**
export const HTML_TEMPLATE = ${JSON.stringify(htmlOutput)};
`;
const formattedTemplateModule = await prettier.format(templateModule, {
parser: 'typescript',
singleQuote: true,
semi: true,
trailingComma: 'all',
printWidth: 80,
tabWidth: 2,
});
await writeFile(join(assetsDistDir, 'index.html'), htmlOutput);
await writeFile(join(packageDistDir, 'index.html'), htmlOutput);
await writeFile(templateModulePath, templateModule);
await writeFile(templateModulePath, formattedTemplateModule);

View file

@ -51,7 +51,11 @@ if (assetBuilds.length === 0) {
const runCommand = ({ command, args, cwd, label }) =>
new Promise((resolve, reject) => {
const child = spawn(command, args, { cwd, stdio: 'inherit' });
const child = spawn(command, args, {
cwd,
stdio: 'inherit',
shell: process.platform === 'win32',
});
child.on('error', reject);
child.on('exit', (code) => {