Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

No more need for this #2

Closed
phated opened this issue Nov 13, 2012 · 5 comments
Closed

No more need for this #2

phated opened this issue Nov 13, 2012 · 5 comments

Comments

@phated
Copy link

phated commented Nov 13, 2012

bower now accepts a .bowerrc file to configure the directory that packages get installed in.

@curist
Copy link
Owner

curist commented Nov 13, 2012

as far as I know, yes, bowerrc can config where we want our packages installed, but Bower installs the whole package.
say, bower install underscore, we will get 31 files, but what we really need is only underscore.js.
and that's where this little plugin comes in handy

@phated
Copy link
Author

phated commented Nov 13, 2012

Makes sense, but maybe this should be renamed, as bower is relatively easy to implement as grunt tasks and this task doesn't expose any of the API.

@curist
Copy link
Owner

curist commented Nov 14, 2012

After a quick reevaluation, I can't really see which/why Bower's API to expose might be useful.
Bower's commands are for one shot thing, excute, and done, I don't think any of the commands will be suitable in a grunt automated task.

But that's only my opinion, would you mind to come up a reason or two which/why Bower's API could be useful if it's exposed?

I'd admit that, this task could be misleading for what it actually does. If there are any better use case for a task named grunt-bower, changing this task's name sure be a good idea.

@phated
Copy link
Author

phated commented Nov 14, 2012

Yeoman and a tool I am working on Grunt-Enyo expose bower through their CLI and both do it through a grunt task. Also, I believe that being able to call grunt.task.run() inside of other tasks to kick off a bower task is better than shelling out or having to implement the API each time it is needed.

@curist
Copy link
Owner

curist commented Nov 15, 2012

  // bower command wrapper
  function bower_wrapper(cmd, done) {
    // pull in the bower command module
    var command = bower.commands[cmd];

    // run
    command.line(process.argv)
      .on('error', grunt.fatal.bind(grunt.fail))
      .on('data', grunt.log.writeln.bind(grunt.log))
      .on('end', function(){
        done();
      });
  }

  // register bower commands as grunt tasks
  Object.keys(bower.commands).forEach(function(cmd) {
    var task_name = 'bower:' + cmd
      , task_desc = 'wrapped bower ' + cmd + 'command.';

    grunt.registerTask(task_name, task_desc, function() {
      var done = this.async();
      bower_wrapper(cmd, done);
    });
  });

Modified from Yeoman's bower task, Bower's commands wrapped as Grunt tasks, with < 30 LOC.

It may be convenient to have these API when working on a framework like Yeoman and Grunt-Enyo, but, just look around other grunt tasks, I don't think this is the way a grunt task should be.

Sure I can plug-in the above codes, but it just doesn't feel right.

@curist curist closed this as completed Nov 23, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants