From 334165ceda51ec0b1267eca65b6f1fda7f29704a Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 14 Nov 2015 00:42:43 +0300 Subject: [PATCH] Promise reject instead of throwing Error --- src/rollup.js | 4 ++-- test/test.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/rollup.js b/src/rollup.js index 0b75d2e..f7a6674 100644 --- a/src/rollup.js +++ b/src/rollup.js @@ -9,11 +9,11 @@ export const VERSION = '<@VERSION@>'; export function rollup ( options ) { if ( !options || !options.entry ) { - throw new Error( 'You must supply options.entry to rollup' ); + return Promise.reject( new Error( 'You must supply options.entry to rollup' ) ); } if ( options.transform || options.load || options.resolveId || options.resolveExternal ) { - throw new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' ); + return Promise.reject( new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' ) ); } const bundle = new Bundle( options ); diff --git a/test/test.js b/test/test.js index 83ed90e..13790be 100644 --- a/test/test.js +++ b/test/test.js @@ -47,13 +47,13 @@ describe( 'rollup', function () { }); it( 'fails without options or options.entry', function () { - assert.throws( function () { - rollup.rollup(); - }, /must supply options\.entry/ ); + rollup.rollup().catch( function (err) { + assert( /must supply options\.entry/.test( err.toString() ) ); + }); - assert.throws( function () { - rollup.rollup({}); - }, /must supply options\.entry/ ); + rollup.rollup().catch( function (err) { + assert( /must supply options\.entry/.test( err.toString() ) ); + }); }); });