Skip to content

Commit adfc973

Browse files
authored
feat: auto update dependency (#36)
1 parent 16e23f7 commit adfc973

2 files changed

Lines changed: 33 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: [master]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
test:
1115
name: Test & Lint

src/templates/registry.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
1+
import { closeSync, existsSync, fstatSync, openSync, readdirSync, readFileSync } from 'fs';
22
import { dirname, join, relative } from 'path';
33
import { fileURLToPath } from 'url';
44

@@ -83,35 +83,47 @@ function readDirectoryRecursively(
8383
return files;
8484
}
8585

86-
const entries = readdirSync(dirPath);
86+
const entries = readdirSync(dirPath, { withFileTypes: true });
8787

8888
for (const entry of entries) {
89-
const fullPath = join(dirPath, entry);
89+
const entryName = entry.name;
90+
const fullPath = join(dirPath, entryName);
9091
const relativePath = relative(basePath, fullPath);
9192

9293
// Skip excluded files
93-
if (exclude.includes(entry) || exclude.includes(relativePath)) {
94+
if (exclude.includes(entryName) || exclude.includes(relativePath)) {
9495
continue;
9596
}
9697

97-
const stat = statSync(fullPath);
98-
99-
if (stat.isDirectory()) {
98+
if (entry.isDirectory()) {
10099
// Recursively read subdirectory
101100
const subFiles = readDirectoryRecursively(fullPath, basePath, exclude);
102101
subFiles.forEach((content, path) => files.set(path, content));
103-
} else if (stat.isFile()) {
104-
// Read file content (skip binary files)
105-
if (!isBinaryFile(fullPath)) {
106-
try {
107-
const content = readFileSync(fullPath, 'utf-8');
102+
} else if (entry.isFile()) {
103+
let fd: number | null = null;
104+
105+
try {
106+
fd = openSync(fullPath, 'r');
107+
const stat = fstatSync(fd);
108+
109+
if (!stat.isFile()) {
110+
continue;
111+
}
112+
113+
// Read file content (skip binary files)
114+
if (!isBinaryFile(fullPath)) {
115+
const content = readFileSync(fd, 'utf-8');
108116
files.set(relativePath, content);
109-
} catch {
110-
// Skip files that can't be read as text
117+
} else {
118+
// For binary files, store a marker to copy them
119+
files.set(relativePath, `__BINARY__:${fullPath}`);
120+
}
121+
} catch {
122+
// Skip files that can't be opened/read
123+
} finally {
124+
if (fd !== null) {
125+
closeSync(fd);
111126
}
112-
} else {
113-
// For binary files, store a marker to copy them
114-
files.set(relativePath, `__BINARY__:${fullPath}`);
115127
}
116128
}
117129
}

0 commit comments

Comments
 (0)