nodecompile.js 1.0 KB

12345678910111213141516171819202122232425262728
  1. // NOTE: This code is called using the jtalkc bash script - do not use directly.
  2. // The arguments variable is a series of .st filenames and category names.
  3. // If it is a .st file we import it, if it is a category name we export it
  4. // as aCategoryName.js.
  5. var sys = require('sys'), fs = require('fs');
  6. // Only care about our arguments, strip away node, all.js and debug flag.
  7. var arguments = process.argv.splice(3);
  8. // First argument is debugMode: "true" or "false"
  9. if (process.argv[2] == "true") {
  10. smalltalk.debugMode = true;
  11. } else {
  12. smalltalk.debugMode = false;
  13. }
  14. console.log("Compiling in debugMode: " + smalltalk.debugMode);
  15. // If it ends with .st, import it, otherwise export category as .js
  16. arguments.forEach(function(val, index, array) {
  17. if (/\.st/.test(val)) {
  18. sys.puts("Reading file " + val);
  19. code = fs.readFileSync(val, "utf8");
  20. smalltalk.Importer._new()._import_(code._stream());
  21. } else {
  22. sys.puts("Exporting category " + val);
  23. fs.writeFileSync(val + ".js", smalltalk.Exporter._new()._exportCategory_(val));
  24. }
  25. });