Defer require until a Color is parsed

This commit is contained in:
Kevin Sawicki
2015-01-13 13:40:42 -08:00
parent 29ee7cc76b
commit 716682f072

View File

@@ -1,5 +1,5 @@
_ = require 'underscore-plus'
ParsedColor = require 'color'
ParsedColor = null
# Essential: A simple color class returned from {Config::get} when the value
# at the key path is of type 'color'.
@@ -16,6 +16,8 @@ class Color
return null if _.isArray(value) or _.isFunction(value)
return null unless _.isObject(value) or _.isString(value)
ParsedColor ?= require 'color'
try
parsedColor = new ParsedColor(value)
catch error