jdan / cleaver

30-second slideshows for hackers
http://jdan.github.io/cleaver
MIT License
4.03k stars 305 forks source link

All theme files required when using local directory? #147

Closed tad-lispy closed 7 years ago

tad-lispy commented 8 years ago

Hello. Thanks for cleaver. It's really great.

While trying to add single script to my presentation using a custom theme I got:

$ cleaver --debug --theme ./cff-theme/ ./presentation.md
  cleaver loaded input document +0ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/templates/layout.mustache +3ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/templates/default.mustache +1ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/templates/author.mustache +0ms
  cleaver loaded templates +0ms
  cleaver parsed options +5ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/resources/default.css +16ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/resources/github.css +1ms
  helper read /Users/tadeuszlazurski/Projects/campaign-frontend/node_modules/cleaver/resources/script.js +0ms
  cleaver loaded static assets +0ms
  helper Error: ENOENT: no such file or directory, open '/Users/tadeuszlazurski/Projects/campaign-frontend/docs/cff-theme/settings.json' /Users/tadeuszlazurski/Projects/campaign-frontend/docs/cff-theme/settings.json +0ms
!! ENOENT: no such file or directory, open '/Users/tadeuszlazurski/Projects/campaign-frontend/docs/cff-theme/settings.json'
Error: ENOENT: no such file or directory, open '/Users/tadeuszlazurski/Projects/campaign-frontend/docs/cff-theme/settings.json'
    at Error (native)

Creating settings.json with {} inside only got me:

!! ENOENT: no such file or directory, open '/Users/tadeuszlazurski/Projects/campaign-frontend/docs/cff-theme/style.css'

According to docs:

a theme may contain:

  • style.css - styles for your presentation
  • template.mustache - a template used to render the slides in your presentation
  • layout.mustache - a template used to render the entire document of your presentation
  • script.js - javascript to be included in your slideshow

A theme does not need to contain all of these files, only the ones present will be loaded into your slideshow.

But it seems that when local directory is specified as a theme all of those files are required.

It works as expected with remote git repo. Maybe ENOENT errors should be ignored for local directory just as 404 errors are ignored for remotes?

tad-lispy commented 8 years ago

Compare this two lines:

https://github.com/jdan/cleaver/blob/master/lib/helper.js#L229 - promise rejected https://github.com/jdan/cleaver/blob/master/lib/helper.js#L220 - promise resolved to empty string

Resolving to empty string in first case would probably fix the issue, but it doesn't seem right to just ignore errors in this general purpose function.

drawveloper commented 8 years ago

Why not check for ENOENT and resolve with empty string?

sudodoki commented 7 years ago

Fixed in 860ec600295e5da381b579887686c30392abee3c. @lzrski closing this for now, let us know if something isn't working for you