run() — svelte Function Reference
Architecture documentation for the run() function in index.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 270fcbf2_b8d1_1068_6dea_98e0b2195a0c["run()"] f3ceb1d6_5cc2_9e87_74da_ca4939313091["index.js"] 270fcbf2_b8d1_1068_6dea_98e0b2195a0c -->|defined in| f3ceb1d6_5cc2_9e87_74da_ca4939313091 style 270fcbf2_b8d1_1068_6dea_98e0b2195a0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/scripts/process-messages/index.js lines 17–408
function run() {
/** @type {Record<string, Record<string, { messages: string[], details: string | null }>>} */
const messages = {};
const seen = new Set();
fs.rmSync(DIR, { force: true, recursive: true });
fs.mkdirSync(DIR);
for (const category of fs.readdirSync('messages')) {
if (category.startsWith('.')) continue;
messages[category] = {};
for (const file of fs.readdirSync(`messages/${category}`)) {
if (!file.endsWith('.md')) continue;
const markdown = fs
.readFileSync(`messages/${category}/${file}`, 'utf-8')
.replace(/\r\n/g, '\n');
const sorted = [];
for (const match of markdown.matchAll(/## ([\w]+)\n\n([^]+?)(?=$|\n\n## )/g)) {
const [_, code, text] = match;
if (seen.has(code)) {
throw new Error(`Duplicate message code ${category}/${code}`);
}
sorted.push({ code, _ });
const sections = text.trim().split('\n\n');
const details = [];
while (!sections[sections.length - 1].startsWith('> ')) {
details.unshift(/** @type {string} */ (sections.pop()));
}
if (sections.length === 0) {
throw new Error('No message text');
}
seen.add(code);
messages[category][code] = {
messages: sections.map((section) => section.replace(/^> /gm, '').replace(/^>\n/gm, '\n')),
details: details.join('\n\n')
};
}
sorted.sort((a, b) => (a.code < b.code ? -1 : 1));
fs.writeFileSync(
`messages/${category}/${file}`,
sorted.map((x) => x._.trim()).join('\n\n') + '\n'
);
}
fs.writeFileSync(
`${DIR}/${category}.md`,
'<!-- This file is generated by scripts/process-messages/index.js. Do not edit! -->\n\n' +
Object.entries(messages[category])
.map(([code, { messages, details }]) => {
const chunks = [
`### ${code}`,
...messages.map((message) => '```\n' + message + '\n```')
];
if (details) {
chunks.push(details);
}
return chunks.join('\n\n');
})
.sort()
.join('\n\n') +
'\n'
);
}
/**
* @param {string} name
Domain
Subdomains
Source
Frequently Asked Questions
What does run() do?
run() is a function in the svelte codebase, defined in packages/svelte/scripts/process-messages/index.js.
Where is run() defined?
run() is defined in packages/svelte/scripts/process-messages/index.js at line 17.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free