@ -1,9 +1,8 @@
const path = require ( 'path' )
const async = require ( 'async' )
const resolvePkg = require ( 'resolve-pkg' )
const Theme = require ( './theme' )
const THUMBSUP _PACKAGES = path . join ( _ _dirname , '..' , '..' , 'node_modules' , '@thumbsup' )
exports . build = function ( rootAlbum , opts , callback ) {
// create the base layer assets
// such as shared JS libs, common handlebars helpers, CSS reset...
@ -13,7 +12,7 @@ exports.build = function (rootAlbum, opts, callback) {
} )
// then create the actual theme assets
const themeDir = opts . themePath || path. join ( THUMBSUP _PACKAGES , ` theme- ${ opts . theme } ` )
const themeDir = opts . themePath || localThemePath( opts . theme )
const theme = new Theme ( themeDir , opts . output , {
stylesheetName : 'theme.css' ,
customStylesPath : opts . themeStyle
@ -58,3 +57,11 @@ function createRenderingTasks (theme, album, gallery, breadcrumbs) {
} )
return tasks
}
function localThemePath ( themeName ) {
const local = resolvePkg ( ` @thumbsup/theme- ${ themeName } ` , { cwd : _ _dirname } )
if ( ! local ) {
throw new Error ( ` Could not find a built-in theme called ${ themeName } ` )
}
return local
}