Sha256: a8a37650025b2fdf5e28ab778223f98a3243b22a9e2130eae2ac496c3db4fb1c

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

var chalk = require('chalk');

function print(msg) {
	console.error(chalk.red(msg)); // eslint-disable-line no-console
}

var handlers = {
	MISSING_INPUT_OPTION: () => {
		print('You must specify an --input (-i) option');
	},

	MISSING_OUTPUT_DIR: () => {
		print(
			'You must specify an --output (-o) option when compiling a directory of files'
		);
	},

	MISSING_OUTPUT_FILE: () => {
		print(
			'You must specify an --output (-o) option when creating a file with a sourcemap'
		);
	},

	ONE_AT_A_TIME: () => {
		print('Bublé can only compile one file/directory at a time');
	},

	DUPLICATE_IMPORT_OPTIONS: () => {
		print('use --input, or pass input path as argument – not both');
	},

	BAD_TARGET: () => {
		print('illegal --target option');
	}
};

module.exports = function handleError(err) {
	var handler;

	if ((handler = handlers[err && err.code])) {
		handler(err);
	} else {
		if (err.snippet) print('---\n' + err.snippet);
		print(err.message || err);

		if (err.stack) {
			console.error(chalk.grey(err.stack)); // eslint-disable-line no-console
		}
	}

	console.error( // eslint-disable-line no-console
		'Type ' +
			chalk.cyan('buble --help') +
			' for help, or visit https://buble.surge.sh/guide/'
	);

	process.exit(1);
};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jass-0.9.5 vendor/node_modules/buble/bin/handleError.js
jass-0.9.4 vendor/node_modules/buble/bin/handleError.js
jass-0.9.3 vendor/node_modules/buble/bin/handleError.js
jass-0.9.1 vendor/node_modules/buble/bin/handleError.js