mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 00:10:15 +00:00
feat: improve ad hoc theme loading
This commit is contained in:
parent
1dbb78c53f
commit
688767d415
25
dist/verbs/build.js
vendored
25
dist/verbs/build.js
vendored
@ -423,19 +423,22 @@ Implementation of the 'build' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_verifyTheme = function(themeNameOrPath) {
|
_verifyTheme = function(themeNameOrPath) {
|
||||||
var exists, tFolder;
|
var exists, tFolder, themesObj;
|
||||||
tFolder = PATH.join(parsePath(require.resolve('fresh-themes')).dirname, '/themes/', themeNameOrPath);
|
themesObj = require('fresh-themes');
|
||||||
exists = require('path-exists').sync;
|
if (_.has(themesObj.themes, themeNameOrPath)) {
|
||||||
if (!exists(tFolder)) {
|
tFolder = PATH.join(parsePath(require.resolve('fresh-themes')).dirname, '/themes/', themeNameOrPath);
|
||||||
|
} else {
|
||||||
tFolder = PATH.resolve(themeNameOrPath);
|
tFolder = PATH.resolve(themeNameOrPath);
|
||||||
if (!exists(tFolder)) {
|
|
||||||
return {
|
|
||||||
fluenterror: HMSTATUS.themeNotFound,
|
|
||||||
data: _opts.theme
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return tFolder;
|
exists = require('path-exists').sync;
|
||||||
|
if (exists(tFolder)) {
|
||||||
|
return tFolder;
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
fluenterror: HMSTATUS.themeNotFound,
|
||||||
|
data: _opts.theme
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,17 +334,30 @@ _expand = ( dst, theTheme ) ->
|
|||||||
Verify the specified theme name/path.
|
Verify the specified theme name/path.
|
||||||
###
|
###
|
||||||
_verifyTheme = ( themeNameOrPath ) ->
|
_verifyTheme = ( themeNameOrPath ) ->
|
||||||
tFolder = PATH.join(
|
|
||||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
# First, see if this is one of the predefined FRESH themes. There are only a
|
||||||
'/themes/',
|
# handful of these, but they may change over time, so we need to query
|
||||||
themeNameOrPath
|
# the official source of truth: the fresh-themes repository, which mounts the
|
||||||
)
|
# themes conveniently by name to the module object, and which is embedded
|
||||||
exists = require('path-exists').sync
|
# locally inside the HackMyResume installation.
|
||||||
if !exists( tFolder )
|
themesObj = require 'fresh-themes'
|
||||||
|
if _.has themesObj.themes, themeNameOrPath
|
||||||
|
tFolder = PATH.join(
|
||||||
|
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||||
|
'/themes/',
|
||||||
|
themeNameOrPath
|
||||||
|
)
|
||||||
|
else
|
||||||
|
# Otherwsie it's a path to an arbitrary FRESH or JRS theme sitting somewhere
|
||||||
|
# on the user's system (or, in the future, at a URI).
|
||||||
tFolder = PATH.resolve themeNameOrPath
|
tFolder = PATH.resolve themeNameOrPath
|
||||||
if !exists tFolder
|
|
||||||
return fluenterror: HMSTATUS.themeNotFound, data: _opts.theme
|
# In either case, make sure the theme folder exists
|
||||||
tFolder
|
exists = require('path-exists').sync
|
||||||
|
if exists tFolder
|
||||||
|
tFolder
|
||||||
|
else
|
||||||
|
fluenterror: HMSTATUS.themeNotFound, data: _opts.theme
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user