Skip to content

Commit cd00e3f

Browse files
committed
Cd into /files if it exists
1 parent f27f104 commit cd00e3f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/web_worker_kernel.ts

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ interface IXeusKernel {
2222

2323
cd(path: string): Promise<void>;
2424

25+
isDir(path: string): Promise<boolean>;
26+
2527
processMessage(msg: any): Promise<void>;
2628
}
2729

@@ -183,6 +185,11 @@ export class WebWorkerKernel implements IKernel {
183185

184186
if (options.mountDrive) {
185187
await this._remote.mount(driveName, '/drive', PageConfig.getBaseUrl());
188+
}
189+
190+
if (await this._remote.isDir('/files')) {
191+
await this._remote.cd('/files');
192+
} else if (options.mountDrive) {
186193
await this._remote.cd(localPath);
187194
}
188195
}

src/worker.ts

+9
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ class XeusKernel {
131131
globalThis.Module.FS.chdir(path);
132132
}
133133

134+
isDir(path: string) {
135+
try {
136+
const lookup = globalThis.Module.FS.lookupPath(path);
137+
return globalThis.Module.FS.isDir(lookup.node.mode);
138+
} catch (e) {
139+
return false;
140+
}
141+
}
142+
134143
async processMessage(event: any): Promise<void> {
135144
const msg_type = event.msg.header.msg_type;
136145

0 commit comments

Comments
 (0)