Search code examples
javascriptangularjscoffeescriptgruntjslinemanjs

Grunt & Lineman - run task with parameters


Is it possible to parametrize already existing grunt task? F.e. there is a pages task where I would like to add some additional actions based on my custom parameter. I've been trying to add something like that in my application.js

...
pages: {
    dev: {
        someParam: true
    }
},
...

and printing it inside pages.coffee:

grunt.registerMultiTask "pages", "generates static HTML files", (someParam) ->
grunt.log.writeln("#{someParam}"); //prints undefined

So it looks like the matter of passing value to task: what am I doing wrong?


Solution

  • Solved it: inside pages.coffee:

    taskConfig = grunt.config.get("pages")
    grunt.log.writeln("${taskConfig.someParam}")
    

    Generally if you would like to override some already defined variables Lineman uses (f.e. source/destination folders) I suggest you to look into node_modules/{module_name}/config/plugins. After analyzing those files you can easily figure out the way how to override some properties (very similar to what I've done in my initial post).