 	@_getDefaultStyle: ->
 		defaultStyle()
 
-	@start: (cb) ->
-		pe = new self
-		pe.start cb
-		pe
+	@start: ->
+		unless instance?
+			instance = new self
+			instance.start()
+
+		instance
+
+	@stop: ->
+		instance?.stop()
 
 	constructor: ->
 		@_maxItems = 50

nodePaths = require './node-paths'
RenderKid = require 'renderkid'

module.exports = class PrettyError
	self = @


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

	start: ->
		@_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

		@

	stop: ->
		Error.prepareStackTrace = @_oldPrepareStackTrace
		@_oldPrepareStackTrace = null

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