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

packageTask dependency #323

Closed reshadi closed 5 years ago

reshadi commented 8 years ago

Hi,

From the code, it looks like the TestTask and PackageTask classes are very similar. The PackageTastk constructor does accept prereqs, but the packageTask() function does not pass the dependencies to the constructor.

As simple fix (in lib/api.js) is like this: this.packageTask = function (name, version, prereqs, definition) { return new jake.PackageTask(name, version, prereqs, definition); };

Or the same pattern that testTask is using can be used for creating the package task. I think this model is actually more preferred and maintainable.

Thanks.

badquanta commented 5 years ago

Just started using Jake and noticed this too. Perhaps the intent is for us to .invoke other tasks within this one?

Am I supposed to do something like: this.packageFiles.toArray().forEach(file => { if (jake.Task[file]) this.prereqs.push(file); });

That works for me when it comes to files defined by the file() function; but it doesn't invoke files defined via rules; unless I'm missing some other way of doing it. I tried just declaring file('name.compiled') with a rule for ('name.source','name.compiled',function(){...}); with it it indicated that the action was missing, so I just went ahead and declared it as a static file for now. Figuring this out; but so far I like it for my project better than gulp.

mde commented 5 years ago

Looks like the constructor correctly handles the prereqs arg as optional, so there's no harm in passing it from the packageTask API method. I'll make that change.

mde commented 5 years ago

Changed and published to NPM, v8.1.1.