gitignore-synthesizer
Version:
Generate smart .gitignore files based on your project's actual contents
25 lines (17 loc) • 639 B
JavaScript
const BASE_URL = 'https://raw.githubusercontent.com/github/gitignore/main/';
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
export async function fetchGitignoreTemplate(framework) {
try {
const url = `${BASE_URL}${capitalize(framework)}.gitignore`;
const res = await fetch(url);
if (!res.ok) {
throw new Error(`Failed to fetch ${framework}.gitignore`);
}
return await res.text();
} catch (err) {
console.error(`[FetchTemplate] Error fetching template for ${framework}:`, err.message);
return ''; // fallback: return empty string
}
}