Skip to content

Commit 11a8f9a

Browse files
xiegeoanishkny
authored andcommitted
use close event call back to fix issue 92 (#93)
https://nodejs.org/api/stream.html#stream_event_close_1
1 parent e9023c1 commit 11a8f9a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

animation/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ async function main() {
5454

5555
const outputdir = await makeTempdir();
5656
const outputGIF = `${outputdir}/output.gif`;
57-
await pngFileStream(`${tempdir}/T*.png`)
57+
pngFileStream(`${tempdir}/T*.png`)
5858
.pipe(encoder.createWriteStream({ repeat: 0, delay: 200, quality: 50 }))
59-
.pipe(fs.createWriteStream(outputGIF));
60-
console.log(`Created session GIF: ${outputGIF}`);
61-
await delay(5000);
62-
execSync(`ls -lhta ${outputdir}`, { stdio: [0, 1, 2] });
63-
64-
if (process.env.CI && process.env.SURGE_LOGIN && process.env.SURGE_TOKEN) {
65-
console.log('Uploading GIF to: http://commit-sudoku.surge.sh/output.gif');
66-
execSync(`SURGE_TOKEN=${process.env.SURGE_TOKEN} npx surge ${outputdir} commit-sudoku.surge.sh`, { stdio: [0, 1, 2] });
67-
}
59+
.pipe(fs.createWriteStream(outputGIF))
60+
.on('close',()=>{
61+
console.log(`Created session GIF: ${outputGIF}`);
62+
execSync(`ls -lhta ${outputdir}`, { stdio: [0, 1, 2] });
63+
if (process.env.CI && process.env.SURGE_LOGIN && process.env.SURGE_TOKEN) {
64+
console.log('Uploading GIF to: http://commit-sudoku.surge.sh/output.gif');
65+
execSync(`SURGE_TOKEN=${process.env.SURGE_TOKEN} npx surge ${outputdir} commit-sudoku.surge.sh`, { stdio: [0, 1, 2] });
66+
}
67+
});
6868
}
6969

7070
function getTableStateForCommit(commitSHA) {

0 commit comments

Comments
 (0)