mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-13 02:41:50 +08:00
fix(core): replace require() with ESM imports in cache-manager
Remove CommonJS require() calls that caused \"require is not defined\"
errors when scanning .workflow directories in ESM context.
Changes:
- Add unlinkSync and readdirSync to fs import statement
- Replace require('fs').unlinkSync() with direct unlinkSync() call
- Replace require('fs').readdirSync() with direct readdirSync() call
Fixes: Cannot scan directory .workflow/active: require is not defined
File: ccw/src/core/cache-manager.ts
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from 'fs';
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync, unlinkSync, readdirSync } from 'fs';
|
||||||
import { join, dirname } from 'path';
|
import { join, dirname } from 'path';
|
||||||
import { StoragePaths, ensureStorageDir } from '../config/storage-paths.js';
|
import { StoragePaths, ensureStorageDir } from '../config/storage-paths.js';
|
||||||
|
|
||||||
@@ -118,8 +118,7 @@ export class CacheManager<T> {
|
|||||||
invalidate(): void {
|
invalidate(): void {
|
||||||
try {
|
try {
|
||||||
if (existsSync(this.cacheFile)) {
|
if (existsSync(this.cacheFile)) {
|
||||||
const fs = require('fs');
|
unlinkSync(this.cacheFile);
|
||||||
fs.unlinkSync(this.cacheFile);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(`Cache invalidation error for ${this.cacheFile}:`, (err as Error).message);
|
console.warn(`Cache invalidation error for ${this.cacheFile}:`, (err as Error).message);
|
||||||
@@ -180,8 +179,7 @@ export class CacheManager<T> {
|
|||||||
if (depth > 3) return; // Limit recursion depth
|
if (depth > 3) return; // Limit recursion depth
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fs = require('fs');
|
const entries = readdirSync(dirPath, { withFileTypes: true });
|
||||||
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const fullPath = join(dirPath, entry.name);
|
const fullPath = join(dirPath, entry.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user