Skip to content

Commit

Permalink
refactor: improve error cases in 'scripts/fetch-asyncapi-example.js' (#…
Browse files Browse the repository at this point in the history
…1364)

Co-authored-by: asyncapi-bot <[email protected]>%0ACo-authored-by: souvik <[email protected]>
  • Loading branch information
peter-rr and Souvikns authored May 17, 2024
1 parent c06a33f commit aff3796
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/fetch-asyncapi-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const unzipAsyncAPIExamples = async () => {
entry.autodrain();
}
}).on('close', () => {
console.log('Unzipped all examples from zip');
console.log('Unzipped all examples from ZIP');
resolve();
}).on('error', () => {
reject();
}).on('error', (error) => {
reject(new Error(`Error in unzipping from ZIP: ${error.message}`));
});
});
};
Expand All @@ -79,11 +79,11 @@ const buildCLIListFromExamples = async () => {

const buildExampleList = examples.map(async example => {
const examplePath = path.join(EXAMPLE_DIRECTORY, example);
const exampleContent = fs.readFileSync(examplePath, { encoding: 'utf-8'});
const exampleContent = fs.readFileSync(examplePath, { encoding: 'utf-8' });

try {
const { document } = await parser.parse(exampleContent);
// Failed for somereason to parse this spec file (document is undefined), ignore for now
// Failed for some reason to parse this spec file (document is undefined), ignore for now
if (!document) {
return;
}
Expand Down Expand Up @@ -114,13 +114,13 @@ const listAllProtocolsForFile = (document) => {
return servers.all().map(server => server.protocol()).join(',');
};

const tidyup = async () => {
const tidyUp = async () => {
fs.unlinkSync(TEMP_ZIP_NAME);
};

(async () => {
await fetchAsyncAPIExamplesFromExternalURL();
await unzipAsyncAPIExamples();
await buildCLIListFromExamples();
await tidyup();
await tidyUp();
})();

0 comments on commit aff3796

Please sign in to comment.