diff --git a/src/index.js b/src/index.js index 5d66136..4ccfb6e 100644 --- a/src/index.js +++ b/src/index.js @@ -330,6 +330,10 @@ const restoreShebangs = (shebangs) => * @throws {Error} If there's a problem while transforming a file. */ const transformOutput = async (files, options) => { + if (!files.length) { + throw new Error('No files to transform were found'); + } + const transformOptions = { verbose: 0, dry: false, diff --git a/tests/index.test.js b/tests/index.test.js index 423b1c1..cb51aaf 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -932,6 +932,20 @@ describe('index', () => { }); }); + it('should throw if the no files are provided', () => { + // Given + const files = []; + const options = { + input: ['src'], + output: 'esm', + }; + expect.assertions(1); + // When + return transformOutput(files, options).catch((error) => { + expect(error.message).toMatch(/No files to transform were found/i); + }); + }); + it('should remove and restore the shebang of a file', async () => { // Given const files = [