Baoyuantop commented on code in PR #2005:
URL: https://github.com/apache/apisix-website/pull/2005#discussion_r2929308608


##########
scripts/generate-website.js:
##########
@@ -3,8 +3,33 @@ const util = require('util');
 const fs = require('fs');
 const path = require('path');
 const { chdir } = require('node:process');
+const { spawn } = require('node:child_process');
 const exec = util.promisify(require('node:child_process').exec);
 
+// Streams stdout/stderr to a log file via spawn (no maxBuffer limit).
+function runBuild(cmd, logFilePath) {
+  return new Promise((resolve) => {
+    const logStream = fs.createWriteStream(logFilePath);
+    const child = spawn(cmd, { shell: true, stdio: ['ignore', 'pipe', 'pipe'] 
});
+
+    child.stdout.pipe(logStream, { end: false });
+    child.stderr.pipe(logStream, { end: false });
+
+    child.on('close', (code) => {
+      logStream.end(() => {
+        resolve({ failed: code !== 0 });
+      });
+    });
+
+    child.on('error', (err) => {
+      logStream.write(`\nError: ${err.message}\n`);
+      logStream.end(() => {
+        resolve({ failed: true });

Review Comment:
   Good catch. Fixed in 72f74b7 — added a `logStream.on('error', ...)` handler 
with a `logStreamFailed` flag that propagates into the resolve result, so the 
build step is marked as failed if the log file can't be written.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to