Skip to content

Commit 0dc9757

Browse files
committed
Fix symbolic link support in yowasp-pack-resources (again).
This time it's for symbolic links to files rather than directories.
1 parent 3638808 commit 0dc9757

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bin/pack-resources.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
import { readdir, readlink, readFile, writeFile, mkdir } from 'fs/promises';
3+
import { readdir, readFile, writeFile, mkdir, stat } from 'fs/promises';
44

55
async function packModules(root, urlRoot) {
66
const files = await readdir(root, { withFileTypes: true });
@@ -22,9 +22,10 @@ async function packDirectory(root, urlRoot, genRoot, dirPath = '', indent = 0) {
2222
for (const file of files) {
2323
packedData.push(`${' '.repeat(indent + 1)}${JSON.stringify(file.name)}: `);
2424
const filePath = `${dirPath}/${file.name}`;
25-
if (file.isDirectory() || file.isSymbolicLink()) {
25+
const fileStats = await stat(`${root}/${dirPath}/${filePath}`);
26+
if (fileStats.isDirectory()) {
2627
packedData.push(await packDirectory(root, urlRoot, genRoot, filePath, indent + 1));
27-
} else if (file.isFile()) {
28+
} else if (fileStats.isFile()) {
2829
const fileData = await readFile(`${root}/${filePath}`);
2930
let emittedAsText = false;
3031
if (fileData.length < 131072) { // emit as a separate file if >128K

0 commit comments

Comments
 (0)