extract-android-device-names.js 508 B

123456789101112131415161718192021
  1. 'use strict';
  2. const csv = require('csv-parser');
  3. const fs = require('node:fs');
  4. const transformResults = res => {
  5. const deviceMapping = {};
  6. res.forEach(({name, model}) => {
  7. if (name && model) {
  8. deviceMapping[model] = name;
  9. }
  10. });
  11. return deviceMapping;
  12. };
  13. const results = [];
  14. fs.createReadStream('supported_devices.csv')
  15. .pipe(csv())
  16. .on('data', data => results.push(data))
  17. .on('end', () => {
  18. fs.writeFileSync('devices.json', JSON.stringify(transformResults(results)));
  19. });