Skip to content

Commit

Permalink
Making ZOS module visible by default when running on ZOS in embedded JS
Browse files Browse the repository at this point in the history
Signed-off-by: JoeNemo <[email protected]>
  • Loading branch information
JoeNemo committed Jul 6, 2023
1 parent a924bdd commit 1b29ddc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions c/configmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,9 +1847,15 @@ static void ensureLE64(){
int main(int argc, char **argv){
LoggingContext *logContext = makeLoggingContext();
logConfigureStandardDestinations(logContext);
if (argc >= 3 && !strcmp("-script",argv[1])){
if (argc >= 3 &&
(!strcmp("-script",argv[1]) ||
!strcmp("-embeddedScript",argv[1]))){
char *filename = argv[2];
EJSNativeModule *modules[1];
int loadMode = EJS_LOAD_IS_MODULE;
if (!strcmp("-embeddedScript",argv[1])){
loadMode = EJS_LOAD_NOT_MODULE;
}
EmbeddedJS *ejs = allocateEmbeddedJS(NULL);
modules[0] = exportConfigManagerToEJS(ejs);
configureEmbeddedJS(ejs,modules,1,argc,argv);
Expand All @@ -1858,7 +1864,7 @@ int main(int argc, char **argv){
fflush(stdout);
fflush(stderr);
*/
int evalStatus = ejsEvalFile(ejs,filename,EJS_LOAD_IS_MODULE);
int evalStatus = ejsEvalFile(ejs,filename,loadMode);
/* printf("Done with EJS: File eval returns %d_______________________________________________\n",evalStatus); */
} else {
return simpleMain(argc,argv);
Expand Down
6 changes: 6 additions & 0 deletions c/embeddedjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,10 +2102,16 @@ bool configureEmbeddedJS(EmbeddedJS *embeddedJS,
if (true){ /* load_std) {*/
const char *source = "import * as std from 'std';\n"
"import * as os from 'os';\n"
#ifdef __ZOWE_OS_ZOS
"import * as zos from 'zos';\n"
#endif
/* "import * as experiment from 'experiment';\n" */
/* "import * as FFI1 from 'FFI1';\n" */
"globalThis.std = std;\n"
"globalThis.os = os;\n"
#ifdef __ZOWE_OS_ZOS
"globalThis.zos = zos;\n"
#endif
/* "globalThis.experiment = experiment;\n"; */
;
size_t sourceLen = strlen(source);
Expand Down

0 comments on commit 1b29ddc

Please sign in to comment.