UI for Zipcoin Blue

get.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const util = require("util");
  5. const chalk_1 = require("chalk");
  6. const errors_1 = require("../../lib/errors");
  7. function get(env, inputs, options) {
  8. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  9. let [p] = inputs;
  10. const { global, json } = options;
  11. if (!global && !env.project.directory) {
  12. throw new errors_1.FatalException(`Sorry--this won't work outside an Ionic project directory. Did you mean to print global config using ${chalk_1.default.green('--global')}?`);
  13. }
  14. const file = global ? env.config : env.project;
  15. const config = yield file.load();
  16. const [cloneDeep, get] = yield Promise.all([Promise.resolve().then(() => require('lodash/cloneDeep')), Promise.resolve().then(() => require('lodash/get'))]);
  17. const v = cloneDeep(p ? get(config, p) : config);
  18. if (json) {
  19. process.stdout.write(JSON.stringify(v));
  20. }
  21. else {
  22. yield sanitize(p, v);
  23. env.log.msg(util.inspect(v, { colors: chalk_1.default.enabled }));
  24. }
  25. });
  26. }
  27. exports.get = get;
  28. function scrubTokens(obj) {
  29. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  30. const mapValues = yield Promise.resolve().then(() => require('lodash/mapValues'));
  31. return mapValues(obj, () => '*****');
  32. });
  33. }
  34. function sanitize(key, obj) {
  35. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  36. const assign = yield Promise.resolve().then(() => require('lodash/assign'));
  37. if (typeof obj === 'object' && 'tokens' in obj) {
  38. obj['tokens'] = yield scrubTokens(obj['tokens']);
  39. }
  40. if (key === 'tokens') {
  41. assign(obj, yield scrubTokens(obj));
  42. }
  43. });
  44. }