private function prepareThemeOptions($themeConfig, $options = null)
    {
        $parsedOptions = null;
        if (!empty($options)) {
            if ('{' == $options[0]) {
                $parsedOptions = json_decode(trim($options), true);
                if (!$parsedOptions || !\is_array($parsedOptions)) {
                    throw new Exception("Unable to parse json from 'theme-options' argument");
                }
            } else {
                if (file_exists($options)) {
                    $unparsed = file_get_contents($options);
                    $parsedOptions = json_decode($unparsed, true);
                    if (!$parsedOptions || !\is_array($parsedOptions)) {
                        throw new Exception(
                            sprintf("Unable to parse json from the file '%s'", $options)
                        );
                    }
                } else {
                    throw new Exception(sprintf("Unable to find file '%s'", $options));
                }
            }
        }

        if (\is_array($parsedOptions)) {
            $options = array_merge($themeConfig['options'], $parsedOptions);
        } else {
            $options = $themeConfig['options'];
        }

        return $options;
    }