@percy/cli-exec 1.27.5-alpha.0 → 1.27.5-beta.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.
Files changed (2) hide show
  1. package/dist/exec.js +31 -4
  2. package/package.json +4 -4
package/dist/exec.js CHANGED
@@ -2,6 +2,8 @@ import command from '@percy/cli-command';
2
2
  import start from './start.js';
3
3
  import stop from './stop.js';
4
4
  import ping from './ping.js';
5
+ import { getPackageJSON } from '@percy/cli-command/utils';
6
+ const pkg = getPackageJSON(import.meta.url);
5
7
  export const exec = command('exec', {
6
8
  description: 'Start and stop Percy around a supplied command',
7
9
  usage: '[options] -- <command>',
@@ -89,7 +91,7 @@ export const exec = command('exec', {
89
91
 
90
92
  // run the provided command
91
93
  log.info(`Running "${[command, ...args].join(' ')}"`);
92
- let [status, error] = yield* spawn(command, args);
94
+ let [status, error] = yield* spawn(command, args, percy);
93
95
 
94
96
  // stop percy if running (force stop if there is an error);
95
97
  await (percy === null || percy === void 0 ? void 0 : percy.stop(!!error));
@@ -100,17 +102,42 @@ export const exec = command('exec', {
100
102
 
101
103
  // Spawn a command with cross-spawn and return an array containing the resulting status code along
102
104
  // with any error encountered while running. Uses a generator pattern to handle interupt signals.
103
- async function* spawn(cmd, args) {
105
+ async function* spawn(cmd, args, percy) {
104
106
  let {
105
107
  default: crossSpawn
106
108
  } = await import('cross-spawn');
107
109
  let proc, closed, error;
108
110
  try {
109
111
  proc = crossSpawn(cmd, args, {
110
- stdio: 'inherit'
112
+ stdio: 'pipe'
111
113
  });
112
- proc.on('close', code => closed = code);
114
+ // Writing stdout of proc to process
115
+ if (proc.stdout) {
116
+ proc.stdout.on('data', data => {
117
+ process.stdout.write(`${data}`);
118
+ });
119
+ }
120
+ if (proc.stderr) {
121
+ proc.stderr.on('data', data => {
122
+ process.stderr.write(`${data}`);
123
+ });
124
+ }
113
125
  proc.on('error', err => error = err);
126
+ proc.on('close', code => {
127
+ closed = code;
128
+ if (code !== 0) {
129
+ // Only send event when there is a global error code and
130
+ // percy token is present
131
+ if (process.env.PERCY_TOKEN) {
132
+ const myObject = {
133
+ errorKind: 'cli',
134
+ cliVersion: pkg.version,
135
+ message: '1'
136
+ };
137
+ percy.client.sendBuildEvents(percy.build.id, myObject);
138
+ }
139
+ }
140
+ });
114
141
 
115
142
  // run until an event is triggered
116
143
  /* eslint-disable-next-line no-unmodified-loop-condition */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-exec",
3
- "version": "1.27.5-alpha.0",
3
+ "version": "1.27.5-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "alpha"
12
+ "tag": "latest"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -33,9 +33,9 @@
33
33
  ]
34
34
  },
35
35
  "dependencies": {
36
- "@percy/cli-command": "1.27.5-alpha.0",
36
+ "@percy/cli-command": "1.27.5-beta.0",
37
37
  "cross-spawn": "^7.0.3",
38
38
  "which": "^2.0.2"
39
39
  },
40
- "gitHead": "8ecc32db25f708a01192b8454d0fdf9c051f48a0"
40
+ "gitHead": "5fed59aa21112e7854a414306504ce7243df7365"
41
41
  }