compile_coffee 929 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. try {
  3. require('shelljs/global');
  4. }
  5. catch (e) {
  6. console.log('Error: shelljs not found. Try reinstalling with npm install --dev');
  7. process.exit(1);
  8. }
  9. var cs = require('coffee-script');
  10. var path = require('path');
  11. console.log('Compiling CoffeeScript');
  12. var files = ls('-R', './src'), file, _in, _out;
  13. for (var i = 0; i < files.length; i++) {
  14. file = files[i];
  15. if (file == 'cli/version.coffee') continue; // written by compile script later
  16. if (file.match(/\.coffee$/)) {
  17. _in = path.join('./src', file)
  18. _out = path.join('./lib', file.replace(/\.coffee$/, '.js'));
  19. console.log(' ' + _in + ' ->' + _out);
  20. cs.compile(cat(_in)).to(_out);
  21. } else {
  22. mkdir('-p', './lib/' + file);
  23. }
  24. }
  25. // write version to lib/cli/version.js
  26. var version = JSON.parse(cat('package.json')).version;
  27. ('module.exports = "' + version + '";\n').to('./lib/cli/version.js');
  28. console.log('Version: '+ version);