Skip to content

Commit

Permalink
Fix if-no-files-found when set to warn (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
qetza authored May 1, 2024
1 parent 06848e0 commit 8bc0cfd
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Upgrade package `@qetza/replacetokens` to `1.7.0`.
- Add support for case insensitive path matching in _sources_ and _variables_.
- Add support for matching directories and files starting with a dot in _sources_ and _variables_.
- Fix _if-no-files-found_ when set to `warn`.

## v1.1.2
- Change telemetry provider.
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63752,8 +63752,10 @@ async function run() {
switch (ifNoFilesFound) {
case 'warn':
core.warning('No files were found with provided sources.');
break;
case 'error':
core.setFailed('No files were found with provided sources.');
break;
default:
core.info('No files were found with provided sources.');
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ export async function run(): Promise<void> {
switch (ifNoFilesFound) {
case 'warn':
core.warning('No files were found with provided sources.');
break;
case 'error':
core.setFailed('No files were found with provided sources.');
break;
default:
core.info('No files were found with provided sources.');
}
Expand Down
64 changes: 64 additions & 0 deletions tests/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,70 @@ describe('run', () => {
);
});

it('if-no-files-found: ignore', async () => {
// arrange
getInputSpy.mockImplementation(name => {
switch (name) {
case 'if-no-files-found':
return 'ignore';
default:
return '';
}
});

replaceTokenSpy.mockResolvedValue({ defaults: 0, files: 0, replaced: 0, tokens: 0, transforms: 0 });

// act
await run();

// assert
expect(setFailedSpy).not.toHaveBeenCalled();

expect(infoSpy).toHaveBeenCalledWith('No files were found with provided sources.');
});

it('if-no-files-found: warn', async () => {
// arrange
getInputSpy.mockImplementation(name => {
switch (name) {
case 'if-no-files-found':
return 'warn';
default:
return '';
}
});

replaceTokenSpy.mockResolvedValue({ defaults: 0, files: 0, replaced: 0, tokens: 0, transforms: 0 });

// act
await run();

// assert
expect(setFailedSpy).not.toHaveBeenCalled();

expect(warningSpy).toHaveBeenCalledWith('No files were found with provided sources.');
});

it('if-no-files-found: error', async () => {
// arrange
getInputSpy.mockImplementation(name => {
switch (name) {
case 'if-no-files-found':
return 'error';
default:
return '';
}
});

replaceTokenSpy.mockResolvedValue({ defaults: 0, files: 0, replaced: 0, tokens: 0, transforms: 0 });

// act
await run();

// assert
expect(setFailedSpy).toHaveBeenCalledWith('No files were found with provided sources.');
});

it('include-dot-paths', async () => {
// arrange
getBooleanInputSpy.mockImplementation(name => {
Expand Down

0 comments on commit 8bc0cfd

Please sign in to comment.