mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 08:03:39 +00:00
feat(coding-agent): add .gitignore to package manager install roots
This commit is contained in:
parent
f832a96bda
commit
2b656c266b
1 changed files with 19 additions and 0 deletions
|
|
@ -92,6 +92,7 @@ export class DefaultPackageManager implements PackageManager {
|
|||
this.cwd = options.cwd;
|
||||
this.agentDir = options.agentDir;
|
||||
this.settingsManager = options.settingsManager;
|
||||
this.ensureGitIgnoreDirs();
|
||||
}
|
||||
|
||||
setProgressCallback(callback: ProgressCallback | undefined): void {
|
||||
|
|
@ -436,6 +437,7 @@ export class DefaultPackageManager implements PackageManager {
|
|||
if (!existsSync(installRoot)) {
|
||||
mkdirSync(installRoot, { recursive: true });
|
||||
}
|
||||
this.ensureGitIgnore(installRoot);
|
||||
const packageJsonPath = join(installRoot, "package.json");
|
||||
if (!existsSync(packageJsonPath)) {
|
||||
const pkgJson = { name: "pi-extensions", private: true };
|
||||
|
|
@ -443,6 +445,23 @@ export class DefaultPackageManager implements PackageManager {
|
|||
}
|
||||
}
|
||||
|
||||
private ensureGitIgnoreDirs(): void {
|
||||
this.ensureGitIgnore(join(this.agentDir, "git"));
|
||||
this.ensureGitIgnore(join(this.agentDir, "npm"));
|
||||
this.ensureGitIgnore(join(this.cwd, CONFIG_DIR_NAME, "git"));
|
||||
this.ensureGitIgnore(join(this.cwd, CONFIG_DIR_NAME, "npm"));
|
||||
}
|
||||
|
||||
private ensureGitIgnore(dir: string): void {
|
||||
if (!existsSync(dir)) {
|
||||
mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
const ignorePath = join(dir, ".gitignore");
|
||||
if (!existsSync(ignorePath)) {
|
||||
writeFileSync(ignorePath, "*\n!.gitignore\n", "utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
private getNpmInstallRoot(scope: SourceScope, temporary: boolean): string {
|
||||
if (temporary) {
|
||||
return this.getTemporaryDir("npm");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue