testfiles.js 809 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env node
  2. var request = require('request')
  3. , path = require('path')
  4. , fs = require('fs');
  5. var files = {
  6. 'pgts.yaml': 'https://raw.github.com/tobie/ua-parser/master/test_resources/pgts_browser_list.yaml'
  7. , 'testcases.yaml': 'https://raw.github.com/tobie/ua-parser/master/test_resources/test_user_agent_parser.yaml'
  8. , 'firefoxes.yaml': 'https://raw.github.com/tobie/ua-parser/master/test_resources/firefox_user_agent_strings.yaml'
  9. };
  10. /**
  11. * Update the fixtures
  12. */
  13. Object.keys(files).forEach(function (key) {
  14. request(files[key], function response (err, res, data) {
  15. if (err || res.statusCode !== 200) return console.error('failed to update');
  16. console.log('downloaded', files[key]);
  17. fs.writeFileSync(path.join(__dirname, '..', 'tests', 'fixtures', key), data);
  18. });
  19. });