1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-24 17:30:10 +00:00

[fix] Replace legacy theme detection code.

This commit is contained in:
hacksalot 2018-01-31 16:00:09 -05:00
parent fde2146a0b
commit 231357badc
No known key found for this signature in database
GPG Key ID: 2F343EC247CA4B06
2 changed files with 32 additions and 6 deletions

8
dist/verbs/build.js vendored
View File

@ -441,12 +441,14 @@ Implementation of the 'build' verb for HackMyResume.
/** /**
Load the specified theme, which could be either a FRESH theme or a JSON Resume Load the specified theme, which could be either a FRESH theme or a JSON Resume
theme. theme (or both).
*/ */
_loadTheme = function(tFolder) { _loadTheme = function(tFolder) {
var theTheme; var exists, theTheme, themeJsonPath;
theTheme = _opts.theme.indexOf('jsonresume-theme-') > -1 ? new JRSTheme().open(tFolder) : new FRESHTheme().open(tFolder); themeJsonPath = PATH.join(tFolder, 'theme.json');
exists = require('path-exists').sync;
theTheme = exists(themeJsonPath) ? new FRESHTheme().open(tFolder) : new JRSTheme().open(tFolder);
_opts.themeObj = theTheme; _opts.themeObj = theTheme;
return theTheme; return theTheme;
}; };

View File

@ -350,15 +350,39 @@ _verifyTheme = ( themeNameOrPath ) ->
###* ###*
Load the specified theme, which could be either a FRESH theme or a JSON Resume Load the specified theme, which could be either a FRESH theme or a JSON Resume
theme. theme (or both).
### ###
_loadTheme = ( tFolder ) -> _loadTheme = ( tFolder ) ->
themeJsonPath = PATH.join tFolder, 'theme.json' # [^1]
exists = require('path-exists').sync
# Create a FRESH or JRS theme object # Create a FRESH or JRS theme object
theTheme = theTheme =
if _opts.theme.indexOf('jsonresume-theme-') > -1 if exists themeJsonPath
then new JRSTheme().open(tFolder) else new FRESHTheme().open( tFolder ); then new FRESHTheme().open tFolder
else new JRSTheme().open tFolder
# Cache the theme object # Cache the theme object
_opts.themeObj = theTheme; _opts.themeObj = theTheme;
theTheme theTheme
# FOOTNOTES
# ------------------------------------------------------------------------------
# [^1] We don't know ahead of time whether this is a FRESH or JRS theme.
# However, all FRESH themes have a theme.json file, so we'll use that as a
# canary for now, as an interim solution.
#
# Unfortunately, with the exception of FRESH's theme.json, both FRESH and
# JRS themes are free-form and don't have a ton of reliable distinguishing
# marks, which makes a simple task like ad hoc theme detection harder than
# it should be to do cleanly.
#
# Another complicating factor is that it's possible for a theme to be BOTH.
# That is, a single set of theme files can serve as a FRESH theme -and- a
# JRS theme.
#
# TODO: The most robust way to deal with all these issues is with a strong
# theme validator. If a theme structure validates as a particular theme
# type, then for all intents and purposes, it IS a theme of that type.