Skip to content

Commit

Permalink
Add symlink support to yowasp-pack-resources.
Browse files Browse the repository at this point in the history
Only symlinks to directories are supported.
  • Loading branch information
whitequark committed Jul 14, 2024
1 parent f1c77fa commit ce3e06c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/pack-resources.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { readdir, readFile, writeFile, mkdir } from 'fs/promises';
import { readdir, readlink, readFile, writeFile, mkdir } from 'fs/promises';

async function packModules(root, urlRoot) {
const files = await readdir(root, { withFileTypes: true });
Expand Down Expand Up @@ -45,6 +45,9 @@ async function packDirectory(root, urlRoot, genRoot, dirPath = '', indent = 0) {
await writeFile(`${genRoot}/${urlRoot}/${filePath}`, fileData);
packedData.push(`new URL(${JSON.stringify(urlRoot + filePath)}, import.meta.url)`);
}
} else if (file.isSymbolicLink()) {
const linkPath = await readlink(`${root}/${filePath}`);
packedData.push(await packDirectory(root, urlRoot, genRoot, linkPath, indent + 1));
} else {
packedData.push('null');
}
Expand Down

0 comments on commit ce3e06c

Please sign in to comment.