1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-17 16:53:13 +00:00

Updated behavior of getJSModule so that the order of precedence matches the recent changes to require()

This commit is contained in:
Bryan Roe
2019-01-29 00:37:29 -08:00
parent 258c1396c7
commit 0557787ceb

View File

@@ -55,9 +55,7 @@ duk_ret_t ILibDuktape_ModSearch_GetJSModule(duk_context *ctx, char *id)
}
duk_pop(ctx); // ...
retVal = ILibHashtable_Get(table, ILibDuktape_ModSearch_ModuleFile, id, idLen);
if (retVal == NULL)
{
duk_push_heap_stash(ctx);
char *mpath;
duk_size_t mpathLen;
@@ -74,17 +72,24 @@ duk_ret_t ILibDuktape_ModSearch_GetJSModule(duk_context *ctx, char *id)
sprintf_s(fileName, idLen + 5 + mpathLen, "%s/%s.js", mpath, id);
}
int dataLen = ILibReadFileFromDiskEx(&retVal, fileName);
if (dataLen > 0) { duk_push_lstring(ctx, retVal, dataLen); free(retVal); }
if (dataLen > 0)
{
duk_push_lstring(ctx, retVal, dataLen); free(retVal);
return(1);
}
else
{
retVal = ILibHashtable_Get(table, ILibDuktape_ModSearch_ModuleFile, id, idLen);
if (retVal == NULL)
{
return(0);
}
}
else
{
duk_push_string(ctx, retVal);
}
return(1);
}
}
}
void ILibDuktape_ModSearch_AddModuleObject(duk_context *ctx, char *id, void *heapptr)
{