| 1 | "use strict"; |
| 2 | |
| 3 | var tz = require('../moment-timezone-utils').tz, |
| 4 | groupLeaders = require('./group-leaders.json'); |
| 5 | |
| 6 | module.exports = function (grunt) { |
| 7 | grunt.registerTask('data-pack', '7. Pack data from data-dedupe.', function (version) { |
| 8 | version = version || 'latest'; |
| 9 | |
| 10 | var unpacked = grunt.file.readJSON('data/unpacked/' + version + '.json'), |
| 11 | output = tz.createLinks(unpacked, groupLeaders); |
| 12 | |
| 13 | output.zones = output.zones.map(function (unpacked) { |
| 14 | return tz.pack(unpacked); |
| 15 | }); |
| 16 | |
| 17 | output.countries = unpacked.countries.map(function (unpacked) { |
| 18 | return tz.packCountry(unpacked); |
| 19 | }); |
| 20 | |
| 21 | grunt.file.write('data/packed/' + version + '.json', JSON.stringify(output, null, '\t')); |
| 22 | if (version === 'latest') { |
| 23 | grunt.file.copy('data/packed/latest.json', 'data/packed/' + unpacked.version + '.json'); |
| 24 | } |
| 25 | |
| 26 | grunt.log.ok('Packed data for ' + version); |
| 27 | }); |
| 28 | }; |