[ci] format

This commit is contained in:
matthewp 2022-08-02 12:10:35 +00:00 committed by fredkbot
parent e33fc9bc46
commit 7d1f86d4b7
2 changed files with 13 additions and 10 deletions

View file

@ -11,12 +11,12 @@ import path from 'path';
import postcssrc from 'postcss-load-config'; import postcssrc from 'postcss-load-config';
import { BUNDLED_THEMES } from 'shiki'; import { BUNDLED_THEMES } from 'shiki';
import { fileURLToPath, pathToFileURL } from 'url'; import { fileURLToPath, pathToFileURL } from 'url';
import * as vite from 'vite';
import { mergeConfig as mergeViteConfig } from 'vite'; import { mergeConfig as mergeViteConfig } from 'vite';
import { z } from 'zod'; import { z } from 'zod';
import { LogOptions } from './logger/core.js'; import { LogOptions } from './logger/core.js';
import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js'; import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js';
import { arraify, isObject } from './util.js'; import { arraify, isObject } from './util.js';
import * as vite from 'vite';
load.use([loadTypeScript]); load.use([loadTypeScript]);
@ -410,8 +410,6 @@ export async function resolveConfigURL(
const flags = resolveFlags(configOptions.flags || {}); const flags = resolveFlags(configOptions.flags || {});
let userConfigPath: string | undefined; let userConfigPath: string | undefined;
if (flags?.config) { if (flags?.config) {
userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`; userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`;
userConfigPath = fileURLToPath(new URL(userConfigPath, `file://${root}/`)); userConfigPath = fileURLToPath(new URL(userConfigPath, `file://${root}/`));
@ -478,7 +476,12 @@ interface TryLoadConfigResult {
filePath?: string; filePath?: string;
} }
async function tryLoadConfig(configOptions: LoadConfigOptions, flags: CLIFlags, userConfigPath: string | undefined, root: string): Promise<TryLoadConfigResult | undefined> { async function tryLoadConfig(
configOptions: LoadConfigOptions,
flags: CLIFlags,
userConfigPath: string | undefined,
root: string
): Promise<TryLoadConfigResult | undefined> {
try { try {
// Automatically load config file using Proload // Automatically load config file using Proload
// If `userConfigPath` is `undefined`, Proload will search for `astro.config.[cm]?[jt]s` // If `userConfigPath` is `undefined`, Proload will search for `astro.config.[cm]?[jt]s`
@ -502,7 +505,7 @@ async function tryLoadConfig(configOptions: LoadConfigOptions, flags: CLIFlags,
// Fallback to use Vite DevServer // Fallback to use Vite DevServer
const viteServer = await vite.createServer({ const viteServer = await vite.createServer({
server: { middlewareMode: true, hmr: false }, server: { middlewareMode: true, hmr: false },
appType: 'custom' appType: 'custom',
}); });
try { try {
const mod = await viteServer.ssrLoadModule(fileURLToPath(configURL)); const mod = await viteServer.ssrLoadModule(fileURLToPath(configURL));
@ -512,7 +515,7 @@ async function tryLoadConfig(configOptions: LoadConfigOptions, flags: CLIFlags,
value: mod.default, value: mod.default,
filePath: fileURLToPath(configURL), filePath: fileURLToPath(configURL),
}; };
}; }
} finally { } finally {
await viteServer.close(); await viteServer.close();
} }

View file

@ -9,7 +9,7 @@ describe('MDX Page', () => {
before(async () => { before(async () => {
fixture = await loadFixture({ fixture = await loadFixture({
root: new URL('./fixtures/mdx-page/', import.meta.url) root: new URL('./fixtures/mdx-page/', import.meta.url),
}); });
}); });