Browse Source

Merge pull request #991 from vforvova/check-options-as-function

Extract options validation into a method
legacy-quote-reserved-properties
Oskar Segersvärd 8 years ago
committed by GitHub
parent
commit
0ac8baf1c9
  1. 16
      src/rollup.js
  2. 6
      src/utils/validateKeys.js

16
src/rollup.js

@ -39,21 +39,25 @@ const ALLOWED_KEYS = [
'useStrict' 'useStrict'
]; ];
export function rollup ( options ) { function checkOptions ( options ) {
if ( !options || !options.entry ) { if ( !options || !options.entry ) {
return Promise.reject( new Error( 'You must supply options.entry to rollup' ) ); return 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 ) {
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' ) ); return 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 error = validateKeys( options, ALLOWED_KEYS ); const error = validateKeys( keys(options), ALLOWED_KEYS );
if ( error ) return error;
if ( error ) { return null;
return Promise.reject( error );
} }
export function rollup ( options ) {
const error = checkOptions ( options );
if ( error ) return Promise.reject( error );
const bundle = new Bundle( options ); const bundle = new Bundle( options );
timeStart( '--BUILD--' ); timeStart( '--BUILD--' );

6
src/utils/validateKeys.js

@ -1,8 +1,4 @@
import { keys } from './object.js'; export default function validateKeys ( actualKeys, allowedKeys ) {
export default function validateKeys ( object, allowedKeys ) {
const actualKeys = keys( object );
let i = actualKeys.length; let i = actualKeys.length;
while ( i-- ) { while ( i-- ) {

Loading…
Cancel
Save