@percy/cli-exec 1.11.0 → 1.13.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.
package/dist/exec.js CHANGED
@@ -11,7 +11,6 @@ export const exec = command('exec', {
11
11
  description: 'Marks the build as one of many parallel builds',
12
12
  parse: () => {
13
13
  var _process$env;
14
-
15
14
  return !!((_process$env = process.env).PERCY_PARALLEL_TOTAL || (_process$env.PERCY_PARALLEL_TOTAL = '-1'));
16
15
  }
17
16
  }, {
@@ -19,7 +18,6 @@ export const exec = command('exec', {
19
18
  description: 'Marks the build as a partial build',
20
19
  parse: () => {
21
20
  var _process$env2;
22
-
23
21
  return !!((_process$env2 = process.env).PERCY_PARTIAL_BUILD || (_process$env2.PERCY_PARTIAL_BUILD = '1'));
24
22
  }
25
23
  }, {
@@ -40,29 +38,28 @@ export const exec = command('exec', {
40
38
  log,
41
39
  exit
42
40
  }) {
43
- var _percy$build;
44
-
45
- let [command, ...args] = argv; // command is required
41
+ var _percy$build, _percy$build2;
42
+ let [command, ...args] = argv;
46
43
 
44
+ // command is required
47
45
  if (!command) {
48
46
  log.error("You must supply a command to run after '--'");
49
47
  log.info('Example:');
50
48
  log.info(' $ percy exec -- npm test');
51
49
  exit(1);
52
- } // verify the provided command exists
53
-
50
+ }
54
51
 
52
+ // verify the provided command exists
55
53
  let {
56
54
  default: which
57
55
  } = await import('which');
58
-
59
56
  if (!which.sync(command, {
60
57
  nothrow: true
61
58
  })) {
62
59
  exit(127, `Command not found "${command}"`);
63
- } // attempt to start percy if enabled
64
-
60
+ }
65
61
 
62
+ // attempt to start percy if enabled
66
63
  if (!percy) {
67
64
  log.warn('Percy is disabled');
68
65
  } else {
@@ -73,41 +70,44 @@ export const exec = command('exec', {
73
70
  log.warn('Skipping visual tests');
74
71
  log.error(error);
75
72
  }
76
- } // provide SDKs with useful env vars
77
-
73
+ }
78
74
 
75
+ // provide SDKs with useful env vars
79
76
  env.PERCY_SERVER_ADDRESS = percy === null || percy === void 0 ? void 0 : percy.address();
80
77
  env.PERCY_BUILD_ID = percy === null || percy === void 0 ? void 0 : (_percy$build = percy.build) === null || _percy$build === void 0 ? void 0 : _percy$build.id;
81
- env.PERCY_LOGLEVEL = log.loglevel(); // run the provided command
78
+ env.PERCY_BUILD_URL = percy === null || percy === void 0 ? void 0 : (_percy$build2 = percy.build) === null || _percy$build2 === void 0 ? void 0 : _percy$build2.url;
79
+ env.PERCY_LOGLEVEL = log.loglevel();
82
80
 
81
+ // run the provided command
83
82
  log.info(`Running "${[command, ...args].join(' ')}"`);
84
- let [status, error] = yield* spawn(command, args); // stop percy if running (force stop if there is an error);
83
+ let [status, error] = yield* spawn(command, args);
85
84
 
86
- await (percy === null || percy === void 0 ? void 0 : percy.stop(!!error)); // forward any returned status code
85
+ // stop percy if running (force stop if there is an error);
86
+ await (percy === null || percy === void 0 ? void 0 : percy.stop(!!error));
87
87
 
88
+ // forward any returned status code
88
89
  if (status) exit(status, error);
89
- }); // Spawn a command with cross-spawn and return an array containing the resulting status code along
90
- // with any error encountered while running. Uses a generator pattern to handle interupt signals.
90
+ });
91
91
 
92
+ // Spawn a command with cross-spawn and return an array containing the resulting status code along
93
+ // with any error encountered while running. Uses a generator pattern to handle interupt signals.
92
94
  async function* spawn(cmd, args) {
93
95
  let {
94
96
  default: crossSpawn
95
97
  } = await import('cross-spawn');
96
98
  let proc, closed, error;
97
-
98
99
  try {
99
100
  proc = crossSpawn(cmd, args, {
100
101
  stdio: 'inherit'
101
102
  });
102
103
  proc.on('close', code => closed = code);
103
- proc.on('error', err => error = err); // run until an event is triggered
104
+ proc.on('error', err => error = err);
104
105
 
106
+ // run until an event is triggered
105
107
  /* eslint-disable-next-line no-unmodified-loop-condition */
106
-
107
108
  while (closed == null && error == null) {
108
109
  yield new Promise(r => setImmediate(r));
109
110
  }
110
-
111
111
  if (error) throw error;
112
112
  return [closed];
113
113
  } catch (err) {
@@ -116,5 +116,4 @@ async function* spawn(cmd, args) {
116
116
  return [0, err];
117
117
  }
118
118
  }
119
-
120
119
  export default exec;
package/dist/ping.js CHANGED
@@ -15,7 +15,6 @@ export const ping = command('ping', {
15
15
  request
16
16
  } = await import('@percy/cli-command/utils');
17
17
  let ping = `http://localhost:${flags.port}/percy/healthcheck`;
18
-
19
18
  try {
20
19
  await request(ping, {
21
20
  retryNotFound: true,
@@ -26,7 +25,6 @@ export const ping = command('ping', {
26
25
  log.debug(err);
27
26
  exit(1);
28
27
  }
29
-
30
28
  log.info('Percy is running');
31
29
  });
32
30
  export default ping;
package/dist/start.js CHANGED
@@ -12,10 +12,10 @@ export const start = command('start', {
12
12
  if (!percy) exit(0, 'Percy is disabled');
13
13
  let {
14
14
  yieldFor
15
- } = await import('@percy/cli-command/utils'); // start percy
15
+ } = await import('@percy/cli-command/utils');
16
16
 
17
+ // start percy
17
18
  yield* percy.yield.start();
18
-
19
19
  try {
20
20
  // run until stopped or terminated
21
21
  yield* yieldFor(() => percy.readyState >= 3);
package/dist/stop.js CHANGED
@@ -16,7 +16,6 @@ export const stop = command('stop', {
16
16
  } = await import('@percy/cli-command/utils');
17
17
  let stop = `http://localhost:${flags.port}/percy/stop`;
18
18
  let ping = `http://localhost:${flags.port}/percy/healthcheck`;
19
-
20
19
  try {
21
20
  await request(stop, {
22
21
  method: 'POST',
@@ -26,9 +25,9 @@ export const stop = command('stop', {
26
25
  log.error('Percy is not running');
27
26
  log.debug(err);
28
27
  exit(1);
29
- } // retry heathcheck until it fails
30
-
28
+ }
31
29
 
30
+ // retry heathcheck until it fails
32
31
  await new Promise(function check(resolve) {
33
32
  return request(ping, {
34
33
  noProxy: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-exec",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,9 +32,9 @@
32
32
  ]
33
33
  },
34
34
  "dependencies": {
35
- "@percy/cli-command": "1.11.0",
35
+ "@percy/cli-command": "1.13.0",
36
36
  "cross-spawn": "^7.0.3",
37
37
  "which": "^2.0.2"
38
38
  },
39
- "gitHead": "0a5043cd677266390889063924f342af9b347055"
39
+ "gitHead": "d2e812d14aa446fa580ffa75144a6280627b5a27"
40
40
  }