Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function checkPublicApi(file: string, expected: string[]) {
const sortedActual = publicApi('modules/' + file).sort();
const sortedExpected = expected.slice().sort((a: string, b: string) => a.localeCompare(b));
const unsorted = expected.find((element, index) => element !== sortedExpected[index]);
const missing = sortedActual.filter((i) => sortedExpected.indexOf(i) < 0);
const extra = sortedExpected.filter((i) => sortedActual.indexOf(i) < 0);
// console.log(sortedActual.join('\',\n \''));
if (unsorted) {
fail(
`The array of expected APIs is incorrectly sorted starting at element:\n ${unsorted}` +
`\n\nexpected: ${sortedActual.join("\n")}`);
}
if (missing.length > 0) {
console.log('=================================================================');
console.log('=================================================================');