Skip to content

Commit 80126b3

Browse files
committed
add first line check to debug output
1 parent 30e2dcb commit 80126b3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const os = require('os');
44
const fs = require('fs');
55
const { Readable } = require('stream');
66
const { finished } = require('stream/promises');
7+
const { createReadStream } = require("fs");
8+
const { createInterface } = require("readline");
79

810
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
911

@@ -38,7 +40,7 @@ async function main(serverUrl, pageId, scope, templateId) {
3840
isFinishedPollData = await isFinishedPollResponse.json();
3941
if (isFinishedPollData.status !== "complete") {
4042
console.log(`Generating at step ${isFinishedPollData.step}: ${isFinishedPollData.stepProgress}%`);
41-
await delay(500);
43+
await delay(1000);
4244
continue;
4345
}
4446
break;
@@ -50,7 +52,16 @@ async function main(serverUrl, pageId, scope, templateId) {
5052
const { body } = await fetch(isFinishedPollData.downloadUrl);
5153
const readableStream = Readable.fromWeb(body);
5254
await finished(readableStream.pipe(stream));
53-
console.log(`Finished downloading. File available at ${filePath}`);
55+
56+
const inputStream = createReadStream(filePath);
57+
let line = '<n/a>';
58+
try {
59+
for await (line of createInterface(inputStream)) break;
60+
}
61+
finally {
62+
inputStream.destroy(); // Destroy file stream.
63+
}
64+
console.log(`Finished downloading. File available at ${filePath}. First line is "${line}"`);
5465

5566
core.setOutput("path", filePath);
5667
} catch (error) {
@@ -65,4 +76,4 @@ async function main(serverUrl, pageId, scope, templateId) {
6576
const scope = core.getInput('scope');
6677
const templateId = core.getInput('template');
6778
await main(serverUrl, pageId, scope, templateId);
68-
})();
79+
})();

0 commit comments

Comments
 (0)