Skip to content

Commit

Permalink
feat: do not fail if banner file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Nov 17, 2016
1 parent 635e2c0 commit 828d912
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = (options = {}) => {

fs.exists(filePath, (exists) => {
if (!exists) {
deferred.reject(new Error(`File ${filePath} does not exist`));
deferred.resolve({code});
return;
}

Expand Down
17 changes: 17 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ describe('rollup-plugin-license', () => {
});
});

it('should not fail if banner file does not exist', (done) => {
const instance = plugin({
file: path.join(__dirname, 'fixtures', 'dummy'),
});

const code = 'var foo = 0;';

const promise = instance.transformBundle(code);

promise.then((result) => {
expect(result).toBeDefined();
expect(result.code).toBeDefined();
expect(result.code).toBe(code);
done();
});
});

it('should prepend banner and create block comment', (done) => {
const instance = plugin({
file: path.join(__dirname, 'fixtures', 'banner.txt'),
Expand Down

0 comments on commit 828d912

Please sign in to comment.