mikesmullin / stylus-lemonade

Automatically Generate CSS Sprites from Images with Stylus
Other
46 stars 3 forks source link

running test error #1

Closed vladbay closed 11 years ago

vladbay commented 11 years ago

Thank you for the plugin! When I try to run the test of integration i see the error:

$ node server.js Wrote ../fixtures/public/stylesheets/application.css. Wrote ../fixtures/public/images/flame-4e9c94d3fa.png. Wrote ../fixtures/public/images/icons-ca35fa0eb8.png. Wrote ../fixtures/public/images/ui-f3b4c8fb16.png. Wrote ../fixtures/public/images/x-b7c3547257.png. Wrote ../fixtures/public/images/y-551357a982.png.

/Users/user/project/node_modules/stylus-lemonade/lib/stylus-lemonade.js:164 callback(null, css); ^ TypeError: undefined is not a function at Lemonade.infect (/Users/user/project/node_modules/stylus-lemonade/lib/stylus-lemonade.js:164:13) at module.exports.async.series.next (/Users/user/project/node_modules/stylus-lemonade/node_modules/mini-async/mini-async.js:14:16) at Sprite.render (/Users/user/project/node_modules/stylus-lemonade/lib/stylus-lemonade.js:336:11) at fs.writeFile (fs.js:746:21) at /Users/user/project/node_modules/stylus-lemonade/node_modules/glob/node_modules/graceful-fs/graceful-fs.js:53:5 at /Users/user/project/node_modules/stylus-lemonade/node_modules/glob/node_modules/graceful-fs/graceful-fs.js:62:5 at Object.oncomplete (fs.js:297:15)

mikesmullin commented 11 years ago

more than likely you'll also need my fork of stylus. i am not sure the patch i submitted will be accepted upstream anytime soon; the author is unresponsive. it hasn't been accepted yet. i have been using npm link to reference my stylus until then.

warning: there is one other limitation of this library: it is currently only capable of making sprite files per-stylesheet. e.g. if you use the same sprite-map filename in two different stylesheets, you'll get two different sprites with the same name but different digest suffices.

so, like compass, it looks like it will need to be integrated at a lower level--like the sprockets level. so i am working on that now. watch these repos for more info soon coffee-sprites, coffee-assets, coffee-stylesheets.

vladbay commented 11 years ago

Yes, it works with your fork of stylus.

But if I delete images from 'node_modules/stylus-lemonade/test/fixtures/public', it returns the error:

../fixtures/private/stylesheets/application.styl:9 5| 6| // Default Functions 7| 8| image-width(img)

9| return image-size(img)[0] 10| 11| image-height(img) 12| return image-size(img)[1]

failed to locate file ../../public/images/money-128x128.png at ".example5" (../fixtures/private/stylesheets/application.styl:56)

at new Image (/Users/vladbay/work/lemonade/node_modules/stylus/lib/functions/image.js:28:25)
at Evaluator.imageSize (/Users/vladbay/work/lemonade/node_modules/stylus/lib/functions/index.js:752:13)
at Evaluator.invokeBuiltin (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:811:30)
at Evaluator.visitCall (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:352:16)
at Evaluator.Visitor.visit (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/index.js:28:40)
at Evaluator.visit (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:75:18)
at Evaluator.visitBinOp (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:406:19)
at Evaluator.Visitor.visit (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/index.js:28:40)
at Evaluator.visit (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:75:18)
at Evaluator.visitExpression (/Users/vladbay/work/lemonade/node_modules/stylus/lib/visitor/evaluator.js:480:26) 

Is it an error in 'application.styl' or the demonstration of lemonode's feature?

In other cases it works great. Thank you very much for your plugin! I look forward to updated stable version of stylus-lemonade in npm-repositary. You are doing really awesome and useful thing.

mikesmullin commented 11 years ago

lol @ lemonnode. well its actually a stylus feature; those are stylus helpers you can find in the official docs (ctrl+f 'image-width'). i have similar ones for sprites called sprite-width() and sprite-height() but they probably behave similarly in the event of a missing file. but make sure you are using the right ones. sometimes the location of the sprite images is not the same location as the public/static images. thats why i made the second pair of functions.

if you are trying to reference an image that really never existed nor will ever exist though, that would be an error in application.styl.

in general i think there's an open TODO written somewhere for validating input to all the defined helper functions, so that invalid input is ignored with a very descriptive error, rather than a cryptic one like that one you got above.

thanks for the positive words. i am more excited to get coffee-assets working soon as it will enable me to have more control over all these types of issues.

if you like this repo, you might also like coffee-templates which is another work in progress. i am developing them all to work together.

vladbay commented 11 years ago

Ok, thanks!