Closed ekhaled closed 9 years ago
Hey @ekhaled ! Thank you for a pull request!
Unfortunately I can't replace grunt.config.get
with grunt.config.getRaw
, because there might me a lot of users relying on that standard grunt functionality.
In your case I would just define the command as a function returning command string.
bgShell:{
install:{
cmd: 'npm install',
bg: true
},
compile:{
cmd: function(){ return 'mv binary folder/' + buildEnv.folder }
}
}
assuming that you will define buildEnv
object in your grunt file.
I see, thanks for pointing out that alternate syntax.
For future reference of people encountering this, I ended up doing it like this:
bgShell:{
install:{
cmd: 'npm install',
bg: true
},
compile:{
cmd: function(){
return grunt.config.process('mv binary folder/<%=buildEnv.folder%>');
}
}
}
Because buildEnv
here wasn't a global variable, it was an object in grunt.initConfig
populated by another task, very similar what grunt-gitinfo does.
This call is just to fetch the
_defaults
object, and we do not need parsed templates here. Because of this, we cannot have template strings on other targets.For example, if I have config something like this:
In the config above
buildEnv
may not be available when we run theinstall
target, it might be injected later from another task usinggrunt.option.set()
before we run thecompile
target. In this case, theinstall
target does not run, becausegrunt.option.get
tries to compile the template string, and fails.