@@ -4,6 +4,8 @@ const os = require('os');
44const fs = require ( 'fs' ) ;
55const { Readable } = require ( 'stream' ) ;
66const { finished } = require ( 'stream/promises' ) ;
7+ const { createReadStream } = require ( "fs" ) ;
8+ const { createInterface } = require ( "readline" ) ;
79
810const 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