Skip to content

Commit

Permalink
fix: copy
Browse files Browse the repository at this point in the history
  • Loading branch information
whes1015 committed Dec 3, 2024
1 parent a8b87fa commit fd682c0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/js/core/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,29 +806,33 @@ class PluginLoader {
await fs.ensureDir(targetPath);

const copyFiles = async (dir, baseTarget, baseSource) => {
const items = await fs.readdir(dir, { withFileTypes: true });
const ignoreFiles = ['.', 'package.json', 'package-lock.json', 'LICENSE'];

for (const item of items) {
if (item.name.startsWith('.') || ignoreFiles.includes(item.name)) {
continue;
}
try {
const items = await fs.promises.readdir(dir, { withFileTypes: true });

await fs.promises.mkdir(baseTarget, { recursive: true });

for (const item of items) {
if (item.name.startsWith('.') || ignoreFiles.includes(item.name)) {
continue;
}

const sourceFull = path.join(dir, item.name);
const targetFull = path.join(baseTarget, path.relative(baseSource, sourceFull));
const sourceFull = path.join(dir, item.name);
const targetFull = path.join(baseTarget, path.relative(baseSource, sourceFull));

try {
if (item.isDirectory()) {
await fs.ensureDir(targetFull);
await fs.promises.mkdir(targetFull, { recursive: true });
await copyFiles(sourceFull, baseTarget, baseSource);
}
else {
await fs.copyFile(sourceFull, targetFull);
await fs.promises.copyFile(sourceFull, targetFull);
}
}
catch (error) {
console.error(`Error copying ${sourceFull}:`, error);
}
}
catch (error) {
console.error(`Error in directory ${dir}:`, error);
throw error;
}
};

Expand Down

0 comments on commit fd682c0

Please sign in to comment.