list-bower-paths
Get paths for bower modules, from the main
property of bower.json
files.
Why?
If you use bower for dependency management, and have a build process that bundles up an app composed of AMD modules (e.g. with the RequireJS optimizer), you probably need to know the location on disk of the modules you're require()
ing.
You can run bower list --path
on the command line, or (if you're using a node.js build tool like grunt or gobble) run it in a child process then capture and parse the result, but boy is it slow. You certainly don't want to have to do it each time you build.
This module offers a better way.
Installation
npm install --save-dev list-bower-paths
Usage
Both asynchronous and synchronous modes are supported.
Async
var lbp = ; // using promises; // using callbacks;
Sync
var lbp = ; var paths = lbp;console;
Options
You can pass in an options object as the first argument:
;
Supported options are:
cwd
- the current working directory. Defaults to the closest directory toprocess.cwd()
that contains a .bowerrc file (orprocess.cwd()
itself, if no .bowerrc can be found)directory
- in the absence of a .bowerrc file, this is where your bower components are located. Defaults tobower_components
relative
- defaults tofalse
. Iftrue
, paths are relative todirectory
noext
- defaults tofalse
. Iftrue
,.js
file extensions are removed (helpful for the RequireJS optimizer, which somehow isn't smart enough to handle file extensions by itself)
License
Released under the MIT License. Copyright 2014 Rich Harris