diff --git a/CHANGELOG.md b/CHANGELOG.md index db917b2..e62409f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/main.ts b/src/main.ts index f7248f3..144ccd9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -159,8 +159,10 @@ export async function run(): Promise { 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.'); } diff --git a/tests/run.test.ts b/tests/run.test.ts index caeb382..5084d86 100644 --- a/tests/run.test.ts +++ b/tests/run.test.ts @@ -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 => {