mhulse / rex

On, Wildfire, on!
http://mhulse.github.io/rex/demo/
Apache License 2.0
4 stars 0 forks source link

Move each regex to its own function ... #115

Closed mhulse closed 11 years ago

mhulse commented 11 years ago

On these lines:

https://github.com/mhulse/rex/blob/gh-pages/source/Gruntfile.js#L440-L450

So I can call them in each dev and prod task. If I do this, I'll probably not need the global option.

See: https://github.com/gruntjs/grunt-contrib-concat/issues/46

The option presented there is a good solution, but in the case of this code, I think I like the idea of having reusable functions.

Note: I tried accessing grunt.task.current.args[0] and this.args and this.name in the process() function call, but it wasn't working. My thought was to say (pseudocode) if (current task is "dev") { do only dev stuff } else { do xxxxx stuff }. Real world example:

// ... snip ...
asciify: {

    // https://oncletom.io/2013/dynamic-grunt-targets-using-templates/
    // Run: grunt all (or) asciify:all:block (where block = font name).
    all: {
        text: '<%= grunt.task.current.args[0] %>',
        options: {
            font: '<%= grunt.task.current.args[0] %>',
            log: true,
        },
    }
},

... above code taken from my post here: https://github.com/olizilla/grunt-asciify/issues/2

Love that technique! I thought it could be useful in this situation, but now I think I like the idea of call the individual regexes as I need them depending on the task (for example, not all regexes need to be run if it's a production build).

mhulse commented 11 years ago

Closed by: b687de00119522cd740237885b4be768f14510d4

It might be nice to make functions more "functional" and modular ... For now, it's not needed, so I'm good with how it is. Just saying, the JS could be written better. Closing for now.