Browse Source

Merge pull request #303 from TrySound/promisify-error

Promise reject instead of throwing Error
better-aggressive
Rich Harris 9 years ago
parent
commit
8334552782
  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 ) { export function rollup ( options ) {
if ( !options || !options.entry ) { 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 ) { 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 ); const bundle = new Bundle( options );

12
test/test.js

@ -47,13 +47,13 @@ describe( 'rollup', function () {
}); });
it( 'fails without options or options.entry', function () { it( 'fails without options or options.entry', function () {
assert.throws( function () { rollup.rollup().catch( function (err) {
rollup.rollup(); assert( /must supply options\.entry/.test( err.toString() ) );
}, /must supply options\.entry/ ); });
assert.throws( function () { rollup.rollup().catch( function (err) {
rollup.rollup({}); assert( /must supply options\.entry/.test( err.toString() ) );
}, /must supply options\.entry/ ); });
}); });
}); });

Loading…
Cancel
Save