From 131c10748301c48ca3d63d03add4866d75d21d76 Mon Sep 17 00:00:00 2001 From: Chirag Date: Fri, 20 Feb 2026 16:03:23 +0530 Subject: [PATCH] feat auto update dependency --- .github/workflows/ci.yml | 4 ++++ src/templates/registry.ts | 46 ++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 692a405..d66cca4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: Test & Lint diff --git a/src/templates/registry.ts b/src/templates/registry.ts index 037d80c..6c6578d 100644 --- a/src/templates/registry.ts +++ b/src/templates/registry.ts @@ -1,4 +1,4 @@ -import { existsSync, readdirSync, readFileSync, statSync } from 'fs'; +import { closeSync, existsSync, fstatSync, openSync, readdirSync, readFileSync } from 'fs'; import { dirname, join, relative } from 'path'; import { fileURLToPath } from 'url'; @@ -83,35 +83,47 @@ function readDirectoryRecursively( return files; } - const entries = readdirSync(dirPath); + const entries = readdirSync(dirPath, { withFileTypes: true }); for (const entry of entries) { - const fullPath = join(dirPath, entry); + const entryName = entry.name; + const fullPath = join(dirPath, entryName); const relativePath = relative(basePath, fullPath); // Skip excluded files - if (exclude.includes(entry) || exclude.includes(relativePath)) { + if (exclude.includes(entryName) || exclude.includes(relativePath)) { continue; } - const stat = statSync(fullPath); - - if (stat.isDirectory()) { + if (entry.isDirectory()) { // Recursively read subdirectory const subFiles = readDirectoryRecursively(fullPath, basePath, exclude); subFiles.forEach((content, path) => files.set(path, content)); - } else if (stat.isFile()) { - // Read file content (skip binary files) - if (!isBinaryFile(fullPath)) { - try { - const content = readFileSync(fullPath, 'utf-8'); + } else if (entry.isFile()) { + let fd: number | null = null; + + try { + fd = openSync(fullPath, 'r'); + const stat = fstatSync(fd); + + if (!stat.isFile()) { + continue; + } + + // Read file content (skip binary files) + if (!isBinaryFile(fullPath)) { + const content = readFileSync(fd, 'utf-8'); files.set(relativePath, content); - } catch { - // Skip files that can't be read as text + } else { + // For binary files, store a marker to copy them + files.set(relativePath, `__BINARY__:${fullPath}`); + } + } catch { + // Skip files that can't be opened/read + } finally { + if (fd !== null) { + closeSync(fd); } - } else { - // For binary files, store a marker to copy them - files.set(relativePath, `__BINARY__:${fullPath}`); } } }