install.js 839 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env node
  2. 'use strict';
  3. const http = require('http');
  4. const fs = require('fs');
  5. const path = require('path');
  6. const { downloadBinary } = require('../js/install');
  7. if (process.env.SENTRYCLI_LOCAL_CDNURL) {
  8. // For testing, mock the CDN by spawning a local server
  9. const server = http.createServer((request, response) => {
  10. const contents = fs.readFileSync(path.join(__dirname, '../js/__mocks__/sentry-cli'));
  11. response.writeHead(200, {
  12. 'Content-Type': 'application/octet-stream',
  13. 'Content-Length': String(contents.byteLength),
  14. });
  15. response.end(contents);
  16. });
  17. server.listen(8999);
  18. process.on('exit', () => server.close());
  19. }
  20. downloadBinary()
  21. .then(() => process.exit(0))
  22. .catch(e => {
  23. // eslint-disable-next-line no-console
  24. console.error(e.toString());
  25. process.exit(1);
  26. });