1 | var chalk = require( 'chalk' );
|
2 |
|
3 | var handlers = {
|
4 | MISSING_INPUT_OPTION: function () {
|
5 | console.error( chalk.red( 'You must specify an --input (-i) option' ) );
|
6 | },
|
7 |
|
8 | MISSING_OUTPUT_OPTION: function () {
|
9 | console.error( chalk.red( 'You must specify an --output (-o) option when creating a file with a sourcemap' ) );
|
10 | },
|
11 |
|
12 | MISSING_NAME: function ( err ) {
|
13 | console.error( chalk.red( 'You must supply a name for UMD exports (e.g. `--name myModule`)' ) );
|
14 | },
|
15 |
|
16 | PARSE_ERROR: function ( err ) {
|
17 | console.error( chalk.red( 'Error parsing ' + err.file + ': ' + err.message ) );
|
18 | },
|
19 |
|
20 | ONE_AT_A_TIME: function ( err ) {
|
21 | console.error( chalk.red( 'rollup can only bundle one file at a time' ) );
|
22 | },
|
23 |
|
24 | DUPLICATE_IMPORT_OPTIONS: function ( err ) {
|
25 | console.error( chalk.red( 'use --input, or pass input path as argument' ) );
|
26 | }
|
27 | };
|
28 |
|
29 | module.exports = function handleError ( err ) {
|
30 | var handler;
|
31 |
|
32 | if ( handler = handlers[ err && err.code ] ) {
|
33 | handler( err );
|
34 | } else {
|
35 | console.error( chalk.red( err.message || err ) );
|
36 |
|
37 | if ( err.stack ) {
|
38 | console.error( chalk.grey( err.stack ) );
|
39 | }
|
40 | }
|
41 |
|
42 | console.error( 'Type ' + chalk.cyan( 'rollup --help' ) + ' for help, or visit https://github.com/rollup/rollup/wiki' );
|
43 |
|
44 | process.exit( 1 );
|
45 | };
|