text: 'use strict';var _fs=require('fs');var _fs2=_interopRequireDefault(_fs);var _commander=require('commander');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}const program=new _commander.Command().usage('<file>').parse(process.argv);function sortObjectKeys(value,deep=false){if(Object(value)===value){if(!Array.isArray(value)){return Object.keys(value).sort(function(l,r){return l.localeCompare(r)}).reduce(function(memo,k){memo[k]=sortObjectKeys(value[k]);return memo},{})}}return value}function readJsonFile(path){return new Promise(function(resolve,reject){_fs2.default.readFile(path,function(err,data){if(err)return reject(err);try{const jsonObject=JSON.parse(data);return resolve(jsonObject)}catch(reason){return reject(reason)}})})}function writeJsonToFile(path,obj){const json=JSON.stringify(obj,null,2);return new Promise(function(resolve,reject){_fs2.default.writeFile(path,`${json}\n`,function(err){if(err)return reject(err);return resolve()})})}if(program.args[0]){const filePath=program.args[0];readJsonFile(filePath).then(function(obj){return sortObjectKeys(obj)}).then(function(obj){return writeJsonToFile(filePath,obj)}).then(function(){console.info(`finished sorting: ${filePath}`)})}else{program.outputHelp(function(help){return help})}
  //# sourceMappingURL=index.js.map