nodecompile.js 571 B

12345678910111213141516
  1. var sys = require('sys'), fs = require('fs');
  2. // Only care about our arguments, strip away node and all.js
  3. var arguments = process.argv.splice(2);
  4. // If it ends with .st, import it, otherwise export category as .js
  5. arguments.forEach(function(val, index, array) {
  6. if (/\.st/.test(val)) {
  7. sys.puts("Reading file " + val);
  8. code = fs.readFileSync(val, "utf8");
  9. smalltalk.Importer._new()._import_(code._stream());
  10. } else {
  11. sys.puts("Exporting category " + val);
  12. fs.writeFileSync(val + ".js", smalltalk.Exporter._new()._exportCategory_(val));
  13. }
  14. });