1
0

nodecompile.js 826 B

1234567891011121314151617181920
  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 and all.js
  7. var arguments = process.argv.splice(2);
  8. // If it ends with .st, import it, otherwise export category as .js
  9. arguments.forEach(function(val, index, array) {
  10. if (/\.st/.test(val)) {
  11. sys.puts("Reading file " + val);
  12. code = fs.readFileSync(val, "utf8");
  13. smalltalk.Importer._new()._import_(code._stream());
  14. } else {
  15. sys.puts("Exporting category " + val);
  16. fs.writeFileSync(val + ".js", smalltalk.Exporter._new()._exportCategory_(val));
  17. }
  18. });