gruntjs / grunt-init

Generate project scaffolding from a template.
http://gruntjs.com/project-scaffolding
MIT License
194 stars 59 forks source link

Scripting Grunt-Init #64

Open mkroehnert opened 11 years ago

mkroehnert commented 11 years ago

Bower supports usage through a public API. It would be great to have the same capabilities for grunt-init. I would like to use grunt-init from inside another program which would include enhancing the search path for template directories.

auscaster commented 10 years ago

@vladikoff this should be pretty straight forward. Is there anything preventing this, and is it something you would like to incorporate?

vladikoff commented 10 years ago

@sourcey feel free to experiment with stuff!

auscaster commented 10 years ago

It seems like the only thing preventing this is that grunt.js needs to expose a runTasks method or similar which can be called programatically... I'll investigate further...

auscaster commented 10 years ago

Created new issue and PR via gruntjs/grunt#1108

mkroehnert commented 10 years ago

Hi @auscaster, thank you very much for working on this issue.

I had a look at the pull request you opened but did not fully understand how it would work with using grunt-init from within JS programs. Since I I'd like to prevent you from doing unnecessary work and to clarify what I had in mind I created a code snippet of how I would like to use grunt-init in a custom project:

var gruntInit = require('grunt-init');

gruntInit.init('template-name', { template-path: 'path/to/custom/location', otherParameter: value } )
.on('end', function (installed) {
    console.log(installed);
});

The .on('end', ...) stuff is taken from the bower example but something similar might be helpful.

auscaster commented 10 years ago

@mkroehnert it seems like I misunderstood the exact issue you were talking about, but all was not in vain since I was able to get grunt to work directly from JS whereas before it wouldn't. Anyway thanks for clarifying the issue, and I'll take another look when time permits.

mkroehnert commented 10 years ago

@auscaster no problem. Upon second look I got what your proposed patch is about. It seems like this is also a nice addition to Grunt itself.