MCPcopy
hub / github.com/rpamis/comet / writeAllWorkflowsToDefaultConfig

Function writeAllWorkflowsToDefaultConfig

src/core/openspec.ts:102–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100}
101
102function writeAllWorkflowsToDefaultConfig(): ConfigBackup | null {
103 const configPath = getOpenSpecDefaultConfigPath();
104 const backupPath = configPath + '.comet-backup';
105 let hadExisting = false;
106
107 try {
108 hadExisting = fs.existsSync(configPath);
109 if (hadExisting) {
110 fs.copyFileSync(configPath, backupPath);
111 }
112
113 const configDir = path.dirname(configPath);
114 if (!fs.existsSync(configDir)) {
115 fs.mkdirSync(configDir, { recursive: true });
116 }
117 fs.writeFileSync(configPath, ALL_WORKFLOWS_CONFIG, 'utf-8');
118
119 return { configPath, backupPath, hadExisting };
120 } catch {
121 if (hadExisting) {
122 try {
123 fs.unlinkSync(backupPath);
124 } catch {
125 // Best-effort cleanup
126 }
127 }
128 return null;
129 }
130}
131
132function restoreDefaultConfig(backup: ConfigBackup | null): void {
133 if (!backup) return;

Callers 1

installOpenSpecFunction · 0.85

Calls 1

Tested by

no test coverage detected