A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
793 B

12 years ago
  1. #!/usr/bin/env node
  2. var path = require('path');
  3. var script = path.basename(__filename);
  4. var errorFile = process.argv[2];
  5. if (!errorFile) {
  6. console.error('Usage: ./' + script + ' path/to/errmsg-utf8.txt');
  7. process.exit(1);
  8. }
  9. var fs = require('fs');
  10. var errors = fs.readFileSync(errorFile, 'utf-8');
  11. var number = Number(errors.match(/start-error-number (\d+)/)[1]);
  12. var codes = errors.match(/^([A-Z_]+)/mg)
  13. var source =
  14. '// Generated by ' + script + ', do not modify by hand\n' +
  15. codes
  16. .map(function(code) {
  17. return 'exports[' + (number++) + '] = \'' + code + '\';';
  18. })
  19. .join('\n');
  20. var targetFile = path.join(__dirname, '../lib/protocol/constants/errors.js');
  21. fs.writeFileSync(targetFile, source, 'utf-8');
  22. console.log('Wrote constants to ' + targetFile);