index.js
function extractMessage(error) {
	var {message} = error
	if (error.plugin === 'babel') {
		// Hey Babel, you're not helping!
		var filepath = error.id
		var message = error.message
		function stripFilePath() {
			var index = message.indexOf(filepath)
			console.log(index, filepath.length)
			message = message.slice(0, index) + message.slice(filepath.length + 1)
			message = message.trim()
		}
		if (message.includes(filepath)) {
			stripFilePath()
		} else {
			filepath = filepath.replace(/\\/g, '/')
			if (message.includes(filepath))
				stripFilePath()
		}
	}
	return message
}
function extractMessage(error) {
	var {message} = error
	if (error.plugin === 'babel') {
		// Hey Babel, you're not helping!
		var filepath = error.id
		var message = error.message
		function stripFilePath() {
			var index = message.indexOf(filepath)
			console.log(index, filepath.length)
			message = message.slice(0, index) + message.slice(filepath.length + 1)
			message = message.trim()
		}
		if (message.includes(filepath)) {
			stripFilePath()
		} else {
			filepath = filepath.replace(/\\/g, '/')
			if (message.includes(filepath))
				stripFilePath()
		}
	}
	return message
}
function extractMessage ( error ) { var { message } = error if ( error . plugin === 'babel' ) { // Hey Babel, you're not helping! var filepath = error . id var message = error . message function stripFilePath ( ) { var index = message . indexOf ( filepath ) console . log ( index , filepath . length ) message = message . slice ( 0 , index ) + message . slice ( filepath . length + 1 ) message = message . trim ( ) } if ( message . includes ( filepath ) ) { stripFilePath ( ) } else { filepath = filepath . replace ( / \\ / g , '/' ) if ( message . includes ( filepath ) ) stripFilePath ( ) } } return message }
Extract only the error message and strip it from file path that might be in there as well.
Extract only the error message and strip it from file path that might be in there as well .