jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

How to intercept jake task loading? #284

Open navneetgarg123 opened 9 years ago

navneetgarg123 commented 9 years ago

I'd like to wrap all of my jake tasks in a function that takes a singular parameter that passes that given to data to the task and do whatever I wish.

jakelib/mytask.jake

function(injector) {
    desk('Some custom task')
    task('something', function() {
        console.log(injector.something)
    });    

Jakefile

var injector = { something: 'Hello world!' };
//Here's where i'd like to load the tasks and pass my injector object
jake.loadTasksWith(injector); 

Is there an interface to make this possible?

mde commented 9 years ago

How is this different from just setting an environment variable when you run Jake?

$ jake fooTask myEnvironmentVariable=bar