bin/post-install.js
function die(reason = "", error = null, exitCode = 0){
	reason = (reason || "").trim();
	
	// ANSI escape sequences (disabled if output is redirected)
	const [reset,, underline,, noUnderline, red] = process.stderr.isTTY
		? [0, 1, 4, 22, 24, [31, 9, 38]].map(s => `\x1B[${ Array.isArray(s) ? s.join(";") : s}m`)
		: Array.of("", 40);
	
	if(error){
		const {inspect} = require("util");
		process.stderr.write(red + inspect(error) + reset + "\n\n");
	}
	
	// Underline all occurrences of target-file's name
	const target = underline + file + noUnderline;
	
	// "Not found" -> "package.json not found"
	if(reason && !reason.match(file))
		reason = (file + " ")
			+ reason[0].toLowerCase()
			+ reason.substr(1);
	
	// Pedantic polishes
	reason = reason
		.replace(/(?:\r\n|\s)+/g,  " ")
		.replace(/^\s+|[.!]*\s*$/g, "")
		.replace(/^(?!\.$)/, ": ")
		.replace(file, target);
	
	const output = `${red}Unable to finish installing Atom-Mocha${reason}${reset}
	
	The following field must be added to your project's ${target} file:
	
		"${key}": "${value}"
	
	See ${underline}README.md${reset} for setup instructions.
	
	`.replace(/^\t/gm, "");
	process.stderr.write(output);
	process.exit(exitCode);
}
function die(reason = "", error = null, exitCode = 0){
	reason = (reason || "").trim();
	
	// ANSI escape sequences (disabled if output is redirected)
	const [reset,, underline,, noUnderline, red] = process.stderr.isTTY
		? [0, 1, 4, 22, 24, [31, 9, 38]].map(s => `\x1B[${ Array.isArray(s) ? s.join(";") : s}m`)
		: Array.of("", 40);
	
	if(error){
		const {inspect} = require("util");
		process.stderr.write(red + inspect(error) + reset + "\n\n");
	}
	
	// Underline all occurrences of target-file's name
	const target = underline + file + noUnderline;
	
	// "Not found" -> "package.json not found"
	if(reason && !reason.match(file))
		reason = (file + " ")
			+ reason[0].toLowerCase()
			+ reason.substr(1);
	
	// Pedantic polishes
	reason = reason
		.replace(/(?:\r\n|\s)+/g,  " ")
		.replace(/^\s+|[.!]*\s*$/g, "")
		.replace(/^(?!\.$)/, ": ")
		.replace(file, target);
	
	const output = `${red}Unable to finish installing Atom-Mocha${reason}${reset}
	
	The following field must be added to your project's ${target} file:
	
		"${key}": "${value}"
	
	See ${underline}README.md${reset} for setup instructions.
	
	`.replace(/^\t/gm, "");
	process.stderr.write(output);
	process.exit(exitCode);
}
function die ( reason = "" , error = null , exitCode = 0 ) { reason = ( reason || "" ) . trim ( ) ; // ANSI escape sequences (disabled if output is redirected) const [ reset , , underline , , noUnderline , red ] = process . stderr . isTTY ? [ 0 , 1 , 4 , 22 , 24 , [ 31 , 9 , 38 ] ] . map ( s => ` \x1B ${ Array . isArray ( s ) ? s . join ( ";" ) : s } ` ) : Array . of ( "" , 40 ) ; if ( error ) { const { inspect } = require ( "util" ) ; process . stderr . write ( red + inspect ( error ) + reset + "\n\n" ) ; } // Underline all occurrences of target-file's name const target = underline + file + noUnderline ; // "Not found" -> "package.json not found" if ( reason && ! reason . match ( file ) ) reason = ( file + " " ) + reason [ 0 ] . toLowerCase ( ) + reason . substr ( 1 ) ; // Pedantic polishes reason = reason . replace ( / (?:\r\n|\s)+ / g , " " ) . replace ( / ^\s+|[.!]*\s*$ / g , "" ) . replace ( / ^(?!\.$) / , ": " ) . replace ( file , target ) ; const output = ` ${ red } ${ reason } ${ reset } ${ target } ${ key } ${ value } ${ underline } ${ reset } ` . replace ( / ^\t / gm , "" ) ; process . stderr . write ( output ) ; process . exit ( exitCode ) ; }
Print an error message to the standard error stream, then quit.

@param {String} [reason=""] - Brief description of the error.
@param {Error} [error=null] - Possible error object preceding output
@param {Number} [exitCode=1] - Error code to exit with.
@private
Print an error message to the standard error stream then quit .