Skip to content

Commit

Permalink
fix message formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Dec 30, 2024
1 parent 11aa73c commit c99579a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Empty file added logs.txt
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export async function runScriptAndGetProcessInfo(
// make sure the process ended
const [exitCode] = await willClose;

const formattedLogRead = '{' + fs.readFileSync(logFile, 'utf-8').slice(0, -3) + '}';
const messages = JSON.parse(formattedLogRead);
// format messages from child process as an object
const messages = (await readFile(logFile, 'utf-8')).trim().split('\n').map(line => JSON.parse(line)).reduce((acc, curr) => ({ ...acc, ...curr }), {});

// delete temporary files
await unlink(scriptName);
Expand Down
2 changes: 1 addition & 1 deletion test/tools/fixtures/process_resource_script.in.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getNewLibuvResourceArray() {

function log(message) {
// remove outer parentheses for easier parsing
const messageToLog = JSON.stringify(message).slice(1, -1) + ', \n';
const messageToLog = JSON.stringify(message) + ' \n';
fs.writeFileSync(logFile, messageToLog, { flag: 'a' });
}

Expand Down

0 comments on commit c99579a

Please sign in to comment.