🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
39
node_modules/astro/dist/cli/load-settings.js
generated
vendored
Normal file
39
node_modules/astro/dist/cli/load-settings.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import * as colors from "kleur/colors";
|
||||
import fs from "node:fs";
|
||||
import { ZodError } from "zod";
|
||||
import { createSettings, openConfig, resolveConfigPath } from "../core/config/index.js";
|
||||
import { collectErrorMetadata } from "../core/errors/dev/index.js";
|
||||
import { error } from "../core/logger/core.js";
|
||||
import { formatConfigErrorMessage, formatErrorMessage } from "../core/messages.js";
|
||||
import * as event from "../events/index.js";
|
||||
import { eventConfigError, telemetry } from "../events/index.js";
|
||||
async function loadSettings({ cmd, flags, logging }) {
|
||||
const root = flags.root;
|
||||
const { astroConfig: initialAstroConfig, userConfig: initialUserConfig } = await openConfig({
|
||||
cwd: root,
|
||||
flags,
|
||||
cmd
|
||||
}).catch(async (e) => {
|
||||
await handleConfigError(e, { cmd, cwd: root, flags, logging });
|
||||
return {};
|
||||
});
|
||||
if (!initialAstroConfig)
|
||||
return;
|
||||
telemetry.record(event.eventCliSession(cmd, initialUserConfig, flags));
|
||||
return createSettings(initialAstroConfig, root);
|
||||
}
|
||||
async function handleConfigError(e, { cmd, cwd, flags, logging }) {
|
||||
const path = await resolveConfigPath({ cwd, flags, fs });
|
||||
error(logging, "astro", `Unable to load ${path ? colors.bold(path) : "your Astro config"}
|
||||
`);
|
||||
if (e instanceof ZodError) {
|
||||
console.error(formatConfigErrorMessage(e) + "\n");
|
||||
telemetry.record(eventConfigError({ cmd, err: e, isFatal: true }));
|
||||
} else if (e instanceof Error) {
|
||||
console.error(formatErrorMessage(collectErrorMetadata(e)) + "\n");
|
||||
}
|
||||
}
|
||||
export {
|
||||
handleConfigError,
|
||||
loadSettings
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue