tools system - web-fetch
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { SEED_PATH, DATA_PATH } from './data-path';
|
||||
|
||||
const SEED_EXTENSIONS_DIR = join(SEED_PATH, 'extensions');
|
||||
const GLOBAL_EXTENSIONS_DIR = join(DATA_PATH, 'extensions');
|
||||
|
||||
export function syncSeedExtensions(): void {
|
||||
if (!existsSync(SEED_EXTENSIONS_DIR)) return;
|
||||
|
||||
mkdirSync(GLOBAL_EXTENSIONS_DIR, { recursive: true });
|
||||
|
||||
const seedEntries = readdirSync(SEED_EXTENSIONS_DIR, { withFileTypes: true });
|
||||
|
||||
for (const entry of seedEntries) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
|
||||
const seedExtensionDir = join(SEED_EXTENSIONS_DIR, entry.name);
|
||||
const entryFile = join(seedExtensionDir, 'index.ts');
|
||||
if (!existsSync(entryFile)) continue;
|
||||
|
||||
const targetDir = join(GLOBAL_EXTENSIONS_DIR, entry.name);
|
||||
|
||||
if (existsSync(targetDir)) {
|
||||
// Extension already exists in DATA_PATH — always overwrite (managed by us, not the user)
|
||||
cpSync(seedExtensionDir, targetDir, { recursive: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
cpSync(seedExtensionDir, targetDir, { recursive: true });
|
||||
console.log(`[extensions] Synced seed extension: ${entry.name}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user