Skip to content

Commit

Permalink
Merge pull request #2474 from newrelic/andrew/data-source-keywords
Browse files Browse the repository at this point in the history
feat: Remove keywords if they're not present
  • Loading branch information
Andrew Anguiano authored Jul 10, 2024
2 parents 269e82d + cff22f9 commit cb84117
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions utils/__tests__/validate_icon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jest.mock('fs');

describe('validate Icon tests', () => {
afterEach(() => {
jest.restoreAllMocks();
jest.resetAllMocks();
});

describe('validateIcon', () => {
Expand Down Expand Up @@ -130,7 +130,6 @@ describe('validate Icon tests', () => {
expect(logMock).toHaveBeenCalledWith(
'No errors found. Icon validation passed.'
);
expect(process.exitCode).toBe(undefined);
});

test('when given errors, prints each error and sets exitCode to 1', () => {
Expand All @@ -139,7 +138,6 @@ describe('validate Icon tests', () => {
handleErrors(['error1', 'error2', 'error3', 'error4']);

expect(logMock).toBeCalledTimes(4);
expect(process.exitCode).toBe(1);
});
});
});
4 changes: 2 additions & 2 deletions utils/lib/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class DataSource extends Component<DataSourceConfig, string> {
displayName: displayName && displayName.trim(),
icon: this._getIconUrl(),
install: this._parseInstall(),
categoryTerms: categoryTerms && categoryTerms.map((t) => t.trim()),
keywords: keywords && keywords.map((k) => k.trim()),
categoryTerms: categoryTerms ? categoryTerms.map((t) => t.trim()): [],
keywords: keywords ? keywords.map((k) => k.trim()) : [],
description: description && description.trim(),
};

Expand Down
6 changes: 4 additions & 2 deletions utils/validate_icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export const handleErrors = (
}

if (errorMessages.length > 0) {
process.exitCode = 1; // fail the workflow

for (const errorMessage of errorMessages) {
console.log(errorMessage);
}
Expand All @@ -58,6 +56,10 @@ const main = () => {
var errorMessages: string[] = validateIcon(mainConfigPaths);
handleErrors(errorMessages);
console.log(''); // add an extra new line for more visual separation in the workflow

if(errorMessages.length) {
process.exit(1);
}
};

/**
Expand Down

0 comments on commit cb84117

Please sign in to comment.