Bun Spawn -> node child process in tools and seed versioning
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
|
||||
import { readdirSync, readFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { SEED_PATH, DATA_PATH } from './data-path';
|
||||
import { parseSeedVersion } from './sync-version';
|
||||
|
||||
const SEED_TOOLS_DIR = join(SEED_PATH, 'tools');
|
||||
const GLOBAL_TOOLS_DIR = join(DATA_PATH, 'tools');
|
||||
@@ -16,14 +17,18 @@ export function syncSeedTools(): void {
|
||||
if (!entry.isDirectory()) continue;
|
||||
|
||||
const seedToolDir = join(SEED_TOOLS_DIR, entry.name);
|
||||
const toolFile = join(seedToolDir, 'TOOL.md');
|
||||
if (!existsSync(toolFile)) continue;
|
||||
const seedFile = join(seedToolDir, 'TOOL.md');
|
||||
if (!existsSync(seedFile)) continue;
|
||||
|
||||
const targetDir = join(GLOBAL_TOOLS_DIR, entry.name);
|
||||
const targetFile = join(targetDir, 'TOOL.md');
|
||||
|
||||
if (existsSync(targetDir)) {
|
||||
// Tool already exists in DATA_PATH — skip to preserve user edits
|
||||
continue;
|
||||
const seedVersion = parseSeedVersion(readFileSync(seedFile, 'utf-8'));
|
||||
const targetVersion = existsSync(targetFile) ? parseSeedVersion(readFileSync(targetFile, 'utf-8')) : 0;
|
||||
if (seedVersion <= targetVersion) continue;
|
||||
rmSync(targetDir, { recursive: true });
|
||||
console.log(`[tools] Updating seed tool: ${entry.name} (v${targetVersion} → v${seedVersion})`);
|
||||
}
|
||||
|
||||
cpSync(seedToolDir, targetDir, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user