curist / grunt-bower

grunt task to copy bower installed packages to other folder(s)
MIT License
93 stars 27 forks source link

Failing to copy components without the "main" property #9

Closed zaim closed 11 years ago

zaim commented 11 years ago

Components without the main property is failing to be copied.

An example of this kind of component is normalize-css: https://github.com/necolas/normalize.css/blob/master/component.json

Running bower list --map (I'm using v0.8.5) yields:

$ bower list --map
{
  "jquery": {
    "source": {
      "main": "components/jquery/jquery.js"
    }
  },
  "normalize-css": {
    "source": {
      "styles": "components/normalize-css/normalize.css"
    }
  }
}

I suggest just using the paths option instead (bower list --paths or bower.commands.list({ paths: true})) as it outputs a normalized list of files, combining the main, styles, etc. properties:

$ bower list --paths
{
  "jquery": "components/jquery/jquery.js",
  "normalize-css": "components/normalize-css/normalize.css"
}

NOTE: Not sure what to make of the styles property since it seems to be undocumented (even the final spec for the main property is still up in the air as the issue is still open)

curist commented 11 years ago

Currently this task only aims for components providing single js file. Components that provide multiple files or multiple file types are not supported.

Maybe you should check grunt-bower-task? It can set different path for each file types.

And, for the using bower list --path part, it's actually used in the early version of grunt-bower. But soon after that I realized that many components registered in Bower registry, don't have proper main property set. Say underscore, requirejs, moment, and so on. These components do show a path in bower list --path, but it's just the installed component's folder path, providing little to none usefulness.

zaim commented 11 years ago

Ok, thanks for clearing that up. I'll check out grunt-bower-task.

But I've decided to cook up my own custom task, anyway. Realized I don't need to complicate things too much :) I posted a gist here