Skip to content

Commit 1fd538b

Browse files
committed
Create parent directory before creating the mount node
1 parent 648696c commit 1fd538b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/php-wasm/node/src/lib/node-fs-mount.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FSHelpers, type MountHandler } from '@php-wasm/universal';
22
import { statSync } from 'fs';
3-
import { basename } from 'path';
3+
import { basename, dirname } from 'path';
44

55
export function createNodeFsMountHandler(localPath: string): MountHandler {
66
return function (php, FS, vfsMountPoint) {
@@ -20,12 +20,14 @@ export function createNodeFsMountHandler(localPath: string): MountHandler {
2020
let removeVfsNode = false;
2121
if (!FSHelpers.fileExists(FS, vfsMountPoint)) {
2222
if (statSync(localPath).isSymbolicLink()) {
23+
FS.mkdirTree(dirname(vfsMountPoint));
2324
(FS as any).createNode(
2425
FS.lookupPath(vfsMountPoint, { parent: true }).node,
2526
basename(localPath),
2627
110000
2728
);
2829
} else if (statSync(localPath).isFile()) {
30+
FS.mkdirTree(dirname(vfsMountPoint));
2931
FS.writeFile(vfsMountPoint, '');
3032
} else if (statSync(localPath).isDirectory()) {
3133
FS.mkdirTree(vfsMountPoint);

0 commit comments

Comments
 (0)