Skip to content

Commit

Permalink
intial POC
Browse files Browse the repository at this point in the history
  • Loading branch information
prklm10 committed Oct 12, 2023
1 parent 932d9ce commit a1f9c5e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log("HEl01")
console.log("HElo2")
console.log("HElo3")
console.log("HElo4")
console.logsd("HElo5")
38 changes: 36 additions & 2 deletions packages/cli-exec/src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const exec = command('exec', {
// attempt to start percy if enabled
if (!percy) {
log.warn('Percy is disabled');
// we can send this data as well.
} else {
try {
// Skip this for app because they are triggered as app:exec
Expand Down Expand Up @@ -97,14 +98,47 @@ export const exec = command('exec', {
async function* spawn(cmd, args) {
let { default: crossSpawn } = await import('cross-spawn');
let proc, closed, error;
let stderrData = '';
let stdoutData = '';

try {
proc = crossSpawn(cmd, args, { stdio: 'inherit' });
proc.on('close', code => (closed = code));
proc = crossSpawn(cmd, args, { stdio: 'pipe' });
// Writing stdout of proc to process
if (proc.stdout) {
proc.stdout.on('data', (data) => {
stdoutData += data;
process.stdout.write(`${data}`);
});
}

if (proc.stderr) {
proc.stderr.on('data', (data) => {
stderrData += data;
process.stderr.write(`${data}`);
});
}

proc.on('error', err => (error = err));

proc.on('close', (code, signal) => {
closed = code;
if (code === 0) {
console.log('Process successfully completed');
} else {
console.error(`Process exited with code ${code}`);
}

//console.error('Stderr:', stderrData);
console.error('stdoutData:', stdoutData.length);
console.error('Stderr:', stderrData.length);
});


// run until an event is triggered
/* eslint-disable-next-line no-unmodified-loop-condition */
// console.error('Stderr:', stderrData);
// console.error('Stderr:', stderrData.length);

while (closed == null && error == null) {
yield new Promise(r => setImmediate(r));
}
Expand Down

0 comments on commit a1f9c5e

Please sign in to comment.