 nodePaths = require './node-paths'
 RenderKid = require 'renderkid'
 
+instance = null
+
 module.exports = class PrettyError
 	self = @
 

		@_style = self._getDefaultStyle()
		@_renderer.style @_style

	start: (cb) ->
		oldPrepareStackTrace = Error.prepareStackTrace

		# https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

		Error.prepareStackTrace = (exc, trace) =>
			stack = oldPrepareStackTrace.apply null, arguments
			@render {stack, message: exc.toString().replace /^.*: /, ''}, no

		process.nextTick cb if cb?
		@

	config: (c) ->
		if c.skipPackages?

	@_getDefaultStyle: ->
		defaultStyle()

	@start: ->
		unless instance?
			instance = new self
			instance.start()

		instance

	@stop: ->
		instance?.stop()

	constructor: ->
		@_maxItems = 50
