From 663e769cdc213f597aa431300c0de7bd10b1ad6a Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Thu, 17 Aug 2017 23:36:55 +0300 Subject: [PATCH] Add a helper script to convert all the tests to yaml --- helpers/convert-old-json-to-yaml.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 helpers/convert-old-json-to-yaml.js diff --git a/helpers/convert-old-json-to-yaml.js b/helpers/convert-old-json-to-yaml.js new file mode 100644 index 0000000..7e4259f --- /dev/null +++ b/helpers/convert-old-json-to-yaml.js @@ -0,0 +1,29 @@ +const fs = require('fs'); +const UAList = require('./src/useragents').useragents; +const json2yaml = require('json2yaml'); +const Parser = require('./lib/parser').default; + +const newBrowserList = {}; + +for (const browserName in UAList) { + const newBrowser = []; + const browserClass = UAList[browserName]; + + for (const browserUA in browserClass) { + const parsedUA = new Parser(browserUA).parse().getResult(); + const newBrowserDeclaration = { + ua: browserUA + }; + // const browserDeclaration = browserClass[browserUA]; + + newBrowserDeclaration.spec = parsedUA; + + newBrowser.push(newBrowserDeclaration); + } + + newBrowserList[browserName] = newBrowser; +} + +const yaml = json2yaml.stringify(newBrowserList); + +fs.writeFileSync('useragentstrings.yml', yaml);