reveal.js 1020 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. module.exports = exports = reveal;
  3. exports.usage = 'Reveals data on the versioned binary';
  4. const versioning = require('./util/versioning.js');
  5. const napi = require('./util/napi.js');
  6. function unix_paths(key, val) {
  7. return val && val.replace ? val.replace(/\\/g, '/') : val;
  8. }
  9. function reveal(gyp, argv, callback) {
  10. const package_json = gyp.package_json;
  11. const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
  12. const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
  13. let hit = false;
  14. // if a second arg is passed look to see
  15. // if it is a known option
  16. // console.log(JSON.stringify(gyp.opts,null,1))
  17. const remain = gyp.opts.argv.remain[gyp.opts.argv.remain.length - 1];
  18. if (remain && Object.hasOwnProperty.call(opts, remain)) {
  19. console.log(opts[remain].replace(/\\/g, '/'));
  20. hit = true;
  21. }
  22. // otherwise return all options as json
  23. if (!hit) {
  24. console.log(JSON.stringify(opts, unix_paths, 2));
  25. }
  26. return callback();
  27. }