Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-generate Tern project files based on bower/npm?

I just integrated Tern with my editor of choice, and the experience has been pretty incredible so far.

One thing that would make the experience all the more intuitive, however, would be the ability to tap into my existing front- and back-end dependency management systems (i.e. the bower.json and package.json files) rather than having to manage the .tern-project file manually.

Is there some existing way of doing this?

like image 442
user456584 Avatar asked Jun 14 '14 14:06

user456584


1 Answers

Setting something like this in your .tern-project should be enough to get it aware of dependencies loaded through your package.json:

{
  "plugins": {
    "node": {}
  }
}

As for bower components, you can follow these steps to get decent completion:

  • Ensure that you have a build step that copies all main js assets from your bower components into a known directory (tools like wiredep are great for this kind of thing).
  • Set that directory into your loadEagerly property.

That'd look something like this:

{
  "loadEagerly": [
    "path/to/Bower/dir/**/*.js"
  ]
}

If your Bower components really rely on them loading in a specific order, you could either list them in the right order in the loadEagerly list, or use the simpler approach of concatenating all these Bower components into a single file and just mentioning that in the loadEagerly list.

like image 85
bilalq Avatar answered Nov 01 '22 00:11

bilalq