Created
May 3, 2012 23:55
-
-
Save ozten/2590547 to your computer and use it in GitHub Desktop.
Boostrap a golden JSON test file into the new golden test file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var new_test_data = { | |
| tests: [] | |
| }; | |
| fs.readFile('data/user_agents.json', 'utf-8', function (err, data) { | |
| if (err) { | |
| console.error(err); | |
| } else { | |
| var test_data = JSON.parse(data); | |
| for (var i=0; i < test_data.tests.length; i++) { | |
| var t = test_data.tests[i]; | |
| if (t.ua) { | |
| var o = coarse.parse(t.ua); | |
| new_test_data.tests.push({ua: t.ua, os: o.os, browser: o.browser, version: o.version}); | |
| console.log(t.ua, 'produces', o); | |
| } else { | |
| new_test_data.tests.push({comment: t.comment}); | |
| console.log('Starting ', t.comment); | |
| } | |
| } | |
| fs.writeFile('data/new_f_user_agents.json', JSON.stringify(new_test_data, null, 2), 'utf8'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment