From 5033db6098fa0db96c45f13ff22be7404672f698 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Sat, 30 Mar 2019 00:41:28 +0000 Subject: [PATCH] changelog-parser: switch the callback params (#34204) * changelog-parser: switch the callback params * changelog-parser: stricter tests --- .../changelog-parser/changelog-parser-tests.ts | 18 +++++++++++++----- types/changelog-parser/index.d.ts | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/types/changelog-parser/changelog-parser-tests.ts b/types/changelog-parser/changelog-parser-tests.ts index 1195d8077f..69a5ffdab3 100644 --- a/types/changelog-parser/changelog-parser-tests.ts +++ b/types/changelog-parser/changelog-parser-tests.ts @@ -5,12 +5,20 @@ const options = { removeMarkdown: false }; -parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (result, error) => {}); +const fn = (obj: object): void => {}; -parseChangelog(options, (result, error) => {}); +parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (error, result) => { + if (error) { + throw error; + } -parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (result) => {}); + fn(result); +}); -parseChangelog(options); +parseChangelog(options, (error, result) => {}); -parseChangelog('path/to/CHANGELOG.md'); +parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (error) => {}); + +parseChangelog(options).then((result) => {}); + +parseChangelog('path/to/CHANGELOG.md').then((result) => {}); diff --git a/types/changelog-parser/index.d.ts b/types/changelog-parser/index.d.ts index 7c03ff3ecd..a1799454c8 100644 --- a/types/changelog-parser/index.d.ts +++ b/types/changelog-parser/index.d.ts @@ -19,6 +19,7 @@ interface Options { /** * Change log parser for node. */ -declare function parseChangelog(options: Partial|string, callback?: (result: object, error: string|null) => void): Promise; +declare function parseChangelog(options: Partial|string, + callback?: (error: string|null, result: object) => void): Promise; export = parseChangelog;