twolfson / spritesmith

Utility that takes sprites and converts them into a stylesheet and its coordinates
MIT License
916 stars 56 forks source link

Support `glob` in src #66

Closed alexander-akait closed 8 years ago

twolfson commented 8 years ago

It's an interesting thought but I think we should pass. It will break backwards compatibility with any files that contain a * in their name as well as add unnecessary code/dependencies. Someone can use glob before passing along src to spritesmith:

var glob = require('glob');
Spritesmith.run({
  src: glob.sync('path/to/files/*.png'),
  ...
}, function () { /* ... */ })
alexander-akait commented 8 years ago

@twolfson sync is not good solution it is slow then async, we have big build and async (speed) is very important

twolfson commented 8 years ago

The example was sync but async can be used as well:

var glob = require('glob');
glob('path/to/files/*.png', function handleGlob (err, files) {
  // If there was an error, handle it as desired
  if (err) {
    throw err;
  }

  // Call spritesmith
  Spritesmith.run({
    src: files,
    ...
  }, function () { /* ... */ })
});
alexander-akait commented 8 years ago

@twolfson I would like to have this opportunity to base, but if this is not feasible so sorry