@testim/testim-cli 3.233.0 → 3.234.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ const TUNNEL_BINARY_PATHNAME = {
15
15
  linuxia32: { path: 'cloudflared-linux-386' },
16
16
  linuxx64: { path: 'cloudflared-linux-amd64' },
17
17
  };
18
- const TUNNEL_BINARY_DIRECTORY = `${os.tmpdir()}/cloudflared`;
18
+ const TUNNEL_BINARY_DIRECTORY = os.tmpdir();
19
19
  const TUNNEL_BINARY_LOCATION = `${TUNNEL_BINARY_DIRECTORY}/cloudflared`;
20
20
 
21
21
 
@@ -32,11 +32,12 @@ async function prepareTunnel() {
32
32
  if (!downloadUrl) {
33
33
  throw new Error(`tunnel on ${os.platform() + os.arch()} platform is not supported.`);
34
34
  }
35
- const destination = downloadUrl.extract ? path.extname(downloadUrl.path) : downloadUrl.path;
35
+ const destination = downloadUrl.extract ? TUNNEL_BINARY_DIRECTORY + downloadUrl.path : TUNNEL_BINARY_LOCATION;
36
36
  await downloadAndSave(`${TUNNEL_BINARY_ORIGIN}/${downloadUrl.path}`, destination);
37
37
  if (downloadUrl.extract) {
38
38
  await unzipFile(destination, TUNNEL_BINARY_DIRECTORY);
39
39
  }
40
+ await fse.chmodSync(TUNNEL_BINARY_LOCATION, '755');
40
41
  }
41
42
 
42
43
  const connectTunnel = async (options) => {
@@ -45,17 +46,18 @@ const connectTunnel = async (options) => {
45
46
  prepareTunnel(),
46
47
  ]);
47
48
  tunnelId = result._id;
48
- tunnelProcess = spawn('./cloudflared', ['tunnel', '--no-autoupdate', 'run', '--force', '--token', result.token], { cwd: TUNNEL_BINARY_DIRECTORY, stdio: 'inherit' });
49
+ tunnelProcess = spawn(TUNNEL_BINARY_LOCATION, ['tunnel', '--no-autoupdate', 'run', '--force', '--token', result.token], { stdio: 'inherit' });
49
50
  await servicesApi.forceUpdateCloudflareTunnelRoutes(options.company.companyId, tunnelId);
50
51
  await fse.writeFileSync(options.tunnelRoutesOutput, JSON.stringify(result.routesMapping, null, 2));
51
52
  };
52
53
 
53
54
  const disconnectTunnel = async (options) => {
55
+ const promises = [];
54
56
  if (tunnelId) {
55
- await servicesApi.deleteCloudflareTunnel(options.company.companyId, tunnelId);
57
+ promises.push(servicesApi.deleteCloudflareTunnel(options.company.companyId, tunnelId));
56
58
  }
57
59
  if (tunnelProcess) {
58
- await new Promise((resolve, reject) => {
60
+ promises.push(new Promise((resolve, reject) => {
59
61
  tunnelProcess.on('close', (code) => {
60
62
  if (code) {
61
63
  reject();
@@ -63,8 +65,9 @@ const disconnectTunnel = async (options) => {
63
65
  resolve();
64
66
  });
65
67
  tunnelProcess.kill();
66
- });
68
+ }));
67
69
  }
70
+ return await Promise.all(promises);
68
71
  };
69
72
 
70
73
  module.exports = {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.233.0",
3
+ "version": "3.234.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@testim/testim-cli",
9
- "version": "3.233.0",
9
+ "version": "3.234.0",
10
10
  "license": "Proprietary",
11
11
  "dependencies": {
12
12
  "@applitools/eyes-sdk-core": "13.2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.233.0",
3
+ "version": "3.234.0",
4
4
  "description": "Command line interface for running Testing on your CI",
5
5
  "author": "Oren Rubin",
6
6
  "contributors": [{
package/processHandler.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-console */
2
+
1
3
  'use strict';
2
4
 
3
5
  const logger = require('./commons/logger').getLogger('process-handler');
@@ -6,9 +8,12 @@ const exitHooks = [];
6
8
  const Promise = require('bluebird');
7
9
 
8
10
  module.exports = function (onExit) {
9
- process.on('uncaughtException', async (err) => {
11
+ async function cleanup(err) {
10
12
  // give cleanup and socket reports a chance to run
11
13
  await Promise.all(exitHooks.map(x => x())).timeout(10000).catch(() => {});
14
+ onExit(err);
15
+ }
16
+ process.on('uncaughtException', async (err) => {
12
17
  logger.error('Caught exception', { err });
13
18
  console.log('Uncaught exception');
14
19
  if (err.message) {
@@ -17,7 +22,7 @@ module.exports = function (onExit) {
17
22
  if (err.reason) {
18
23
  console.log('Reason =', err.reason);
19
24
  }
20
- onExit(err);
25
+ await cleanup(err);
21
26
  });
22
27
 
23
28
  process.on('unhandledRejection', (reason) => {
@@ -40,7 +45,7 @@ module.exports = function (onExit) {
40
45
  const msg = 'Runner aborted - SIGTERM event';
41
46
  const err = new Error(msg);
42
47
  logger.error(msg);
43
- onExit(err);
48
+ cleanup(err);
44
49
  throw err;
45
50
  });
46
51
 
@@ -48,7 +53,7 @@ module.exports = function (onExit) {
48
53
  const msg = 'Runner aborted - SIGINT event';
49
54
  const err = new Error(msg);
50
55
  logger.error(msg);
51
- onExit(err);
56
+ cleanup(err);
52
57
  throw err;
53
58
  });
54
59