bower-requirejs
Advanced tools
Comparing version 0.8.6 to 0.9.0
@@ -25,6 +25,4 @@ #!/usr/bin/env node | ||
var args = opts.argv.remain; | ||
function init() { | ||
project(args, opts); | ||
project(opts); | ||
} | ||
@@ -31,0 +29,0 @@ |
@@ -17,4 +17,3 @@ 'use strict'; | ||
*/ | ||
module.exports = function (args, opts, done) { | ||
args = args || []; | ||
module.exports = function (opts, done) { | ||
opts = opts || {}; | ||
@@ -21,0 +20,0 @@ |
{ | ||
"name": "bower-requirejs", | ||
"version": "0.8.6", | ||
"version": "0.9.0", | ||
"description": "Automagically wire-up installed Bower components into your RequireJS config", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -61,2 +61,67 @@ # bower-requirejs [![Build Status](https://secure.travis-ci.org/yeoman/bower-requirejs.png?branch=master)](http://travis-ci.org/yeoman/bower-requirejs) | ||
## Programmatic API | ||
### bowerRequireJS(options, callback) | ||
- `options` — An [options object](https://github.com/yeoman/bower-requirejs#options) containing a config and optional baseUrl and excludes. | ||
- `callback` — A callback to execute when the task is finished | ||
You can use `bower-requirejs` directly in your app if you prefer to not rely on the binary. | ||
```js | ||
var bowerRequireJS = require('bower-requirejs'); | ||
var options = { | ||
config: 'scripts/config.js', | ||
exclude: ['underscore', 'jquery'] | ||
}; | ||
bowerRequrieJS(options, function () { | ||
// all done! | ||
}); | ||
``` | ||
### parse(pkg, name, baseUrl) | ||
- `pkg` — A package object returned from `bower list` | ||
- `name` — The name of the package | ||
- `baseUrl` — A baseUrl to use when generating the path | ||
If you would like to just receive a paths object you can do so with the `parse` module. If your package does not contain a `bower.json` file, or if the `bower.json` does not contain a `main` attribute then the parse module will try to use the `primary` module to find a primary, top-level js file. | ||
```js | ||
var bower = require('bower'); | ||
var _ = require('lodash'); | ||
var parse = require('bower-requirejs/lib/parse'); | ||
var baseUrl = './'; | ||
bower.commands.list() | ||
.on('end', function (data) { | ||
_.forOwn(data.dependencies, function (pkg, name) { | ||
if (name == 'jquery') { | ||
var pathObj = parse(pkg, name, baseUrl); | ||
} | ||
}); | ||
}); | ||
``` | ||
### primary(name, canonicalDir) | ||
- `name` — The package name | ||
- `canonicalDir` — The canonicalDir for the package, either returned by `bower list` or passed in manually | ||
If you just want to look for the top-level js file in a bower component you can use the `primary` module. The `primary` module will exclude gruntfiles and `min.js` files. It will also check if `package.json` specifies a `main` js file. | ||
```js | ||
var primary = require('bower-requirejs/lib/primary'); | ||
var name = 'backbone'; | ||
var dep = { canonicalDir: './bower_components/backbone' }; | ||
var primaryJS = primary(name, dep); | ||
// returns backbone.js | ||
``` | ||
## Credit | ||
@@ -63,0 +128,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17886
136
426