Skip to content

Commit 779d311

Browse files
Merge pull request #405 from LambdaTest/prod
back sync
2 parents 29ddb23 + 209cc54 commit 779d311

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.38-beta.0",
3+
"version": "4.1.38-beta.1",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/tasks/exec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import chalk from 'chalk'
44
import spawn from 'cross-spawn'
55
import { updateLogContext } from '../lib/logger.js'
66
import { startPolling, startSSEListener } from '../lib/utils.js'
7+
import fs from 'fs'
8+
import path from 'path'
79

810
export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRendererFactory> => {
911
return {
@@ -38,6 +40,25 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
3840
})
3941
childProcess.stdout?.pipe(output);
4042
childProcess.stderr?.pipe(output);
43+
} else {
44+
// Write logs to file when skipping terminal output
45+
const logFileName = `execution-logs.log`;
46+
const logFilePath = path.join(process.cwd(), logFileName);
47+
const logStream = fs.createWriteStream(logFilePath, { flags: 'a' });
48+
49+
task.output = chalk.gray(`Execution logs being written to: ${logFileName}`);
50+
51+
childProcess.stdout?.on('data', (data) => {
52+
logStream.write(data);
53+
});
54+
55+
childProcess.stderr?.on('data', (data) => {
56+
logStream.write(data);
57+
});
58+
59+
childProcess.on('close', () => {
60+
logStream.end();
61+
});
4162
}
4263

4364
childProcess.on('error', (error) => {

0 commit comments

Comments
 (0)