Skip to content

Commit 16fbd41

Browse files
fix: file not found error when preview html(#1301)
* fix. file not found error * format
1 parent c90fc7b commit 16fbd41

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/lib/run.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ async function run(
6060
const uuid = helpers.uuid();
6161

6262
let isLoading = false;
63+
let isFallback = false;
6364
let filename, pathName, extension;
6465
let port = appSettings.value.serverPort;
6566
let EXECUTING_SCRIPT = uuid + "_script.js";
@@ -252,7 +253,7 @@ async function run(
252253

253254
let file = activeFile.SAFMode === "single" ? activeFile : null;
254255

255-
if (pathName) {
256+
if (pathName && isFallback) {
256257
const projectFolder = addedFolder[0];
257258

258259
//set the root folder to the file parent if no project folder is set
@@ -478,10 +479,20 @@ async function run(
478479
* @returns
479480
*/
480481
async function sendFileContent(url, id, mime, processText) {
481-
const fs = fsOperation(url);
482+
let fs = fsOperation(url);
482483

483484
if (!(await fs.exists())) {
484-
error(id);
485+
const xfs = fsOperation(Url.join(pathName, filename));
486+
487+
if (await xfs.exists()) {
488+
fs = xfs;
489+
isFallback = true;
490+
console.log(`fallback ${Url.join(pathName, filename)}`);
491+
} else {
492+
console.log(`${url} doesnt exists`);
493+
error(id);
494+
}
495+
485496
return;
486497
}
487498

0 commit comments

Comments
 (0)