Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

main-bower-files

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

main-bower-files - npm Package Compare versions

Comparing version
2.9.0
to
2.11.0
.tern-project

Sorry, the diff of this file is not supported yet

+15
{
"dependencies": {
"simple": "*",
"overwritten": "*",
"multi": "*",
"ignore": "*",
"hasPackageNoBower": "*",
"deepPaths":"*",
"decoy": "*"
},
"group": {
"group1": [ "simple", "multi" ],
"containDepsError": [ "simple", "nonExistingModule" ]
}
}
+1
-1

@@ -21,3 +21,3 @@ var readFile = require('fs').readFileSync,

filter = null;
} else if (typeof filter !== 'string' && Array.isArray(filter) === false) {
} else if (typeof filter !== 'string' && Array.isArray(filter) === false && !(filter instanceof RegExp)) {
if (typeof opts === 'function') {

@@ -24,0 +24,0 @@ cb = opts;

@@ -71,2 +71,3 @@ var path = require('path'),

var name,
group = this.opts.group || null,
includeDev = this.opts.includeDev || false,

@@ -83,16 +84,31 @@ includeSelf = this.opts.includeSelf || false,

if (includeDev !== 'exclusive') {
for (name in dependencies) {
this.add(name, path.join(this.opts.paths.bowerDirectory, path.sep, name));
// add packages from group option or add packages entirely from bower file
if (group && bowerJson.group) {
if (!bowerJson.group[group]) {
throw new Error('group "' + group + '" does not exists in bower.json');
}
}
if (includeDev !== false) {
for (name in devDependencies) {
this.add(name, path.join(this.opts.paths.bowerDirectory, path.sep, name));
var deps = bowerJson.group[group];
if (deps instanceof Array) {
for (var i in deps) {
this.add(deps[i], path.join(this.opts.paths.bowerDirectory, path.sep, deps[i]));
}
}
}
} else {
if (includeDev !== 'exclusive') {
for (name in dependencies) {
this.add(name, path.join(this.opts.paths.bowerDirectory, path.sep, name));
}
}
if (includeSelf !== false) {
this.add(main, path.join(path.dirname(this.opts.paths.bowerJson)));
if (includeDev !== false) {
for (name in devDependencies) {
this.add(name, path.join(this.opts.paths.bowerDirectory, path.sep, name));
}
}
if (includeSelf !== false) {
this.add(main, path.join(path.dirname(this.opts.paths.bowerJson)));
}
}

@@ -99,0 +115,0 @@ },

{
"name": "main-bower-files",
"version": "2.9.0",
"version": "2.11.0",
"description": "Get main files from your installed bower packages.",

@@ -5,0 +5,0 @@ "main": "index.js",

+68
-18

@@ -31,5 +31,6 @@ main-bower-files

If first argument is type of `String` or `Array` it will be used as a filter, otherwise it will be used as options.
If first argument is type of `String`, `Array` or `RegExp` it will be used as a filter, otherwise it will be used as options.
This will read your `bower.json`, iterate through your dependencies and returns an array of filesdefined in the main property of the packages `bower.json`.
This will read your `bower.json`, iterate through your dependencies and returns an array of files defined in the main property of the packages `bower.json`.
You can override the behavior if you add an `overrides` property to your own `bower.json`.

@@ -52,2 +53,3 @@

`mainBowerFiles` returns an array of files where each file is a absolute path without any globs (** or *). gulp requires globs in these paths to apply the base path. Because of this, you always have to tell gulp your bower base path (the path to the bower_components directory) explicitly.
Here is an example:

@@ -68,3 +70,5 @@

### Usage with grunt
Install this plugin with the following command:
```bash

@@ -75,2 +79,3 @@ npm install --save-dev main-bower-files

Once that's done, add this line to your project's Gruntfile:
```javascript

@@ -81,2 +86,3 @@ grunt.loadNpmTasks('main-bower-files');

In your project's Gruntfile, add a section named `bower` to the data object passed into `grunt.initConfig()`, like so:
```javascript

@@ -130,3 +136,4 @@ grunt.initConfig({

Type: `String` or `Array` or `Object`
Type: `String` or `Array` or `Object`
You can specify which files should be selected. You can `main-bower-files` select files based on the `process.env.NODE_ENV` if you provide an `Object` with `keys` as the environment, e.g.:

@@ -161,3 +168,4 @@

Type: `Boolean` Default: `false`
Type: `Boolean` Default: `false`
Set to `true` if you want to ignore this package.

@@ -167,3 +175,4 @@

Type: `Object`
Type: `Object`
You can override the dependencies of a package. Set to `null` to ignore the dependencies.

@@ -177,3 +186,4 @@

Type: `boolean` Default: `false`
Type: `boolean` Default: `false`
Set to `true` to enable debugging output.

@@ -183,3 +193,4 @@

Type: `String` or `Array` or `Object` Default: `null`
Type: `String` or `Array` or `Object` Default: `null`
You can specify for all packages a default main property which will be used if the package does not provide a main property.

@@ -189,3 +200,4 @@

Type: `String` Default: `process.env.NODE_ENV`
Type: `String` Default: `process.env.NODE_ENV`
If `process.env.NODE_ENV` is not set you can use this option.

@@ -195,5 +207,8 @@

Type: `Object` or `String`
Type: `Object` or `String`
You can specify the paths where the following bower specific files are located:
`bower_components`, `.bowerrc` and `bower.json`
`bower_components`, `.bowerrc` and `bower.json`
For example:

@@ -212,3 +227,4 @@

If a `String` is supplied instead, it will become the basepath for default paths.
If a `String` is supplied instead, it will become the basepath for default paths.
For example:

@@ -229,4 +245,6 @@

Type: `boolean` Default: `false`
Type: `boolean` Default: `false`
Set this to true if you want that the plugin checks every file for existence.
If enabled and a file does not exists, the plugin will throw an exception.

@@ -236,4 +254,6 @@

Type: `mixed` Default: `false`
Type: `mixed` Default: `false`
You can include your devDependencies in two ways:
* Set this option to `inclusive` or true to add the devDependencies to your dependencies

@@ -244,7 +264,10 @@ * or use `exclusive` to exclude your dependencies

Type: `boolean` Default: `false`
Type: `boolean` Default: `false`
Set this to true to add the main files to your dependencies
### filter
Type: `RegExp` or `function` or `glob` Default: `null`
Type: `RegExp` or `function` or `glob` Default: `null`
You can filter the list of files by a regular expression, glob or callback function (the first and only argument is the file path).

@@ -254,5 +277,33 @@

Type: `object` Default: `{}`
Set default overrides option which can be overriden in the `overrides` section of the `bower.json`
Type: `object` Default: `{}`
Set default overrides option which can be overridden in the `overrides` section of the `bower.json`
### group
Type: `String` Default: `null`
You can specify a group of dependencies you want to read from bower.json
For example:
```json
{
"dependencies": {
"BOWER-PACKAGE-1": "*",
"BOWER-PACKAGE-2": "*",
"BOWER-PACKAGE-3": "*",
"BOWER-PACKAGE-4": "*"
},
"group": {
"home": [ "BOWER-PACKAGE-1" ],
"admin": [ "BOWER-PACKAGE-1", "BOWER-PACKAGE-2", "BOWER-PACKAGE-3" ]
}
}
```
```javascript
mainBowerFiles({ paths: 'path/for/project', group: 'home' });
```
## LICENSE

@@ -282,2 +333,1 @@

WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -30,3 +30,3 @@ var mainBowerFiles = require('../'),

if (typeof filter === 'string' || Array.isArray(filter)) {
if (typeof filter === 'string' || Array.isArray(filter) || filter instanceof RegExp) {
delete options.filter;

@@ -293,2 +293,34 @@ srcFiles = mainBowerFiles(filter, options, options.callback || undefined);

});
it('should select all files if no group options pass to function', function(done) {
expect([
'/fixtures/simple/simple.js',
'/fixtures/overwritten/overwritten.js',
'/fixtures/multi/multi.js',
'/fixtures/multi/multi.css',
'/fixtures/hasPackageNoBower/hasPackageNoBower.js',
'/fixtures/deepPaths/lib/deeppaths.js',
'/fixtures/decoy/decoy.js'
]).fromConfig('/_bower_with_group.json').when(done);
});
it('should select the expected files from group propery in bower.json', function(done) {
expect([
'/fixtures/simple/simple.js',
'/fixtures/multi/multi.js',
'/fixtures/multi/multi.css'
]).fromConfig('/_bower_with_group.json', { group: 'group1' }).when(done);
});
it('should throw an exception if group name does not exist', function() {
var when = expect([]).fromConfig('/_bower_with_group.json', { group: 'nonExistingGroup' }).when;
when.should.throw('group "nonExistingGroup" does not exists in bower.json');
});
it('should ignore nonexisting packages in the group', function(done) {
expect([
'/fixtures/simple/simple.js'
]).fromConfig('/_bower_with_group.json', { group: 'containDepsError' }).when(done);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet