Browse Source

Promise reject instead of throwing Error

better-aggressive
Bogdan Chadkin 9 years ago
parent
commit
334165ceda
  1. 4
      src/rollup.js
  2. 12
      test/test.js

4
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 );

12
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() ) );
});
});
});

Loading…
Cancel
Save