• R/O
  • SSH
  • HTTPS

nina: Commit


Commit MetaInfo

Revision680 (tree)
Time2018-11-23 17:40:05
Authory-moriguchi

Log Message

supports Node.js module

Change Summary

Incremental Difference

--- nina/java/translator/net/morilib/nina/translate/AbstractNinaTranslator.java (revision 679)
+++ nina/java/translator/net/morilib/nina/translate/AbstractNinaTranslator.java (revision 680)
@@ -767,6 +767,7 @@
767767 env.bind("SKIP_SPACES", q.getOptionNvl("whiteSpaces", " \\t\\n"));
768768 env.bind("SHEBANG", q.getOptionNvl("shebang", ""));
769769 env.bind("PUT_WINDOWS_BATCH", q.getOptionNvl("windowsBatchCommand", ""));
770+ env.bind("JS_MODULE_EXPORT", q.getOptionNvl("javascriptModuleExport", ""));
770771 env.bind("CR", "\r");
771772
772773 if("prompt".equals(q.getOption("main"))) {
--- nina/java/translator/net/morilib/nina/translate/nina_template.dfa.js.sub1.sh (revision 679)
+++ nina/java/translator/net/morilib/nina/translate/nina_template.dfa.js.sub1.sh (revision 680)
@@ -1182,6 +1182,15 @@
11821182 do
11831183 print_constants $i
11841184 done
1185+
1186+dollarRoot='$root'
1187+[ -n "$USE_IMMEDIATE_FN" ] && [ -n "$JS_MODULE_EXPORT" ] && cat << EOF
1188+ if(typeof module !== "undefined" && module.exports) {
1189+ module.exports = $JS_MODULE_EXPORT;
1190+ } else {
1191+ $dollarRoot["$JS_MODULE_EXPORT"] = $JS_MODULE_EXPORT;
1192+ }
1193+EOF
11851194 echo '/* @@@-PARSER-CODE-END-@@@ */'
11861195
11871196 cat fragment
Show on old repository browser