@percy/cli-exec 1.27.4-beta.1 → 1.27.4-beta.3
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 +31 -4
- package/package.json +3 -3
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: '
|
|
112
|
+
stdio: 'pipe'
|
|
111
113
|
});
|
|
112
|
-
|
|
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.4-beta.
|
|
3
|
+
"version": "1.27.4-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@percy/cli-command": "1.27.4-beta.
|
|
36
|
+
"@percy/cli-command": "1.27.4-beta.3",
|
|
37
37
|
"cross-spawn": "^7.0.3",
|
|
38
38
|
"which": "^2.0.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "e560f5df1637d30722f8d1d7e6eae9cf99ede2dd"
|
|
41
41
|
}
|