Skip to content

Commit e90ad43

Browse files
committed
Fix regression of symlink handling during packing.
1 parent 3957521 commit e90ad43

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

bin/pack-resources.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,22 @@ const filesystem = async (fetch) => ({
7272

7373
if (shareDirectory !== undefined) {
7474
const tarEntries = [];
75-
for (const dirent of await readdir(shareDirectory, { withFileTypes: true, recursive: true })) {
76-
const name = `${dirent.parentPath}/${dirent.name}`.replace(`${shareDirectory}/`, '');
77-
if (dirent.isDirectory()) {
78-
tarEntries.push({name: name});
79-
} else if (dirent.isFile()) {
80-
tarEntries.push({name, data: await readFile(`${dirent.parentPath}/${dirent.name}`)});
75+
async function archivePath(pathName) {
76+
const pathStat = await stat(pathName);
77+
const tarName = pathName.replace(`${shareDirectory}/`, '');
78+
if (pathStat.isDirectory()) {
79+
if (pathName !== shareDirectory)
80+
tarEntries.push({name: tarName});
81+
for (const name of await readdir(pathName))
82+
await archivePath(`${pathName}/${name}`);
83+
} else if (pathStat.isFile()) {
84+
tarEntries.push({name: tarName, data: await readFile(pathName)});
8185
} else {
82-
console.error(`Unsupported type of '${dirent.name}'!`);
86+
console.error(`Unsupported type of '${pathName}'!`);
8387
process.exit(2);
8488
}
8589
}
86-
90+
await archivePath(shareDirectory);
8791
const tarData = createTar(tarEntries);
8892
const tarFilePath = resourceFilePath.replace(/\.js$/, '.tar');
8993
await writeFile(tarFilePath, tarData);

test/yowasp_runtime_test/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ if ((await yowaspRuntimeTest.run(['share/bar/baz.txt', 'bar.txt'], {}))['bar.txt
1212
throw 'test 1 failed (2)';
1313
if ((await yowaspRuntimeTest.run(['share/bar/cat/stat.txt', 'bar.txt'], {}))['bar.txt'] !== 'im drumnk\n')
1414
throw 'test 1 failed (3)';
15+
if ((await yowaspRuntimeTest.run(['share/sym.txt', 'bar.txt'], {}))['bar.txt'] !== 'meow\n')
16+
throw 'test 1 failed (4)';
17+
if ((await yowaspRuntimeTest.run(['share/cat/stat.txt', 'bar.txt'], {}))['bar.txt'] !== 'im drumnk\n')
18+
throw 'test 1 failed (5)';
1519

1620
if ((await yowaspRuntimeTest.run(['baz.txt', 'bar.txt'], {'baz.txt': 'contents of baz'}))['bar.txt'] !== 'contents of baz')
1721
throw 'test 2 failed';

test/yowasp_runtime_test/share/cat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bar/cat
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bar/baz.txt

0 commit comments

Comments
 (0)