nx/packages/next/src/utils/add-gitignore-entry.ts
2024-02-16 16:36:01 -05:00

20 lines
449 B
TypeScript

import { Tree } from 'nx/src/generators/tree';
import ignore from 'ignore';
export function addGitIgnoreEntry(host: Tree) {
if (!host.exists('.gitignore')) {
return;
}
let content = host.read('.gitignore', 'utf-8').trimEnd();
const ig = ignore();
ig.add(host.read('.gitignore', 'utf-8'));
if (!ig.ignores('apps/example/.next')) {
content = `${content}\n\n# Next.js\n.next\nout\n`;
}
host.write('.gitignore', content);
}