bpierre / fontello-svg

Generate SVG icons from a Fontello icon set.
MIT License
65 stars 7 forks source link

Provide a Grunt task #1

Open lolmaus opened 10 years ago

lolmaus commented 10 years ago

Hi!

Thank you for the awesome tool! It does its job fine and save my time. You're awesome!

I decided to include fontello-svg into my deployment routine. I ended up using a grunt-shell task with these options:

shell: {                                // Task

        generateFontelloIcons: {            // Target
            options: {                      // Options
                stdout: true,
                stderr: true
            },
            command: "node_modules/.bin/fontello-svg -c fontello.json -o 'source/assets/images/icons' -f 'black:#000 | grey-dusty:#999 | grey-emperor:#555 | grey-mineshaft:#333 | white:#fff | red-guardsman:#b00'"
        }

    }

This work, but this is not a graceful way of using a Node.js package in Grunt.

I thought that i would just peek into the bin file bin/fontello-svg and create a simple custom Grunt task based on the bin file, but i discovered that the bin file contains 100 lines of code, and my total lack of Node.js knowledge prevents me from making a Grunt task out of it.

I humbly request that you consider refactoring fontello-svg and publishing a Grunt task that allows leveraging fontello-svg with a graceful Grunt config. Could be something like this:

module.exports = function(grunt) {
  grunt.initConfig({        

    fontello-svg: {
      config: 'fontello.json',
      output_dif: 'source/assets/images/icons',
      create_css: false,
      fill_colors: {
        black: '#000',
        grey-dusty: '#999',
        grey-emperor: '#555',
        grey-mineshaft: '#333',
        white: '#fff',
        red-guardsman: '#b00'
      }
    }

  });
}
bpierre commented 10 years ago

Glad to see that fontello-svg helps other people!

I am not really interested in Grunt, but maybe I could write a function to handle everything the way the binary currently does to make things easier.

This function (e.g. fontelloSvg(configFile, outDirectory, fillColors)) would be used by bin/fontello-svg, and it would be easy to develop a Grunt plugin on top of it.

If you’re willing to write it provided that I commit this new function, I will of course gladly accept a pull request for adding a Grunt plugin to the project.

lolmaus commented 10 years ago

I have no experience in the Node.js land, but i think that my client-side JS skill is enough to let me create a Grunt task.

The only thing that i doubt is that i'll be able to create a task in the existing project. There's a tutorial how to create a Grunt task in a website's Gruntfile.js, and a guide how to create and publish a Grunt task as a separate NPM package, but i found no information on how to embed a task in an existing NPM package.