Skip to content

Commit

Permalink
rename option to maintainScope
Browse files Browse the repository at this point in the history
  • Loading branch information
Bret Ikehara committed Oct 25, 2016
1 parent 38cfe62 commit f5db6b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ gulpLoadPlugins({
rename: {}, // a mapping of plugins to rename
renameFn: function (name) { ... }, // a function to handle the renaming of plugins (the default works)
postRequireTransforms: {}, // see documentation below
scoped: true // loads all npm scopes like non-scoped packages
maintainScope: true // toggles loadin all npm scopes like non-scoped packages
});
```

Expand Down Expand Up @@ -118,19 +118,19 @@ Note that if you specify the `renameFn` options with your own custom rename func

## npm Scopes

`gulp-load-plugins` comes with [npm scope](https://docs.npmjs.com/misc/scope) support. By default, the scoped plugins are accessible through an object on `plugins` that represents the scope. When `scoped = false`, the plugins are availble in the top level just like any other non-scoped plugins.
`gulp-load-plugins` comes with [npm scope](https://docs.npmjs.com/misc/scope) support. By default, the scoped plugins are accessible through an object on `plugins` that represents the scope. When `maintainScope = false`, the plugins are availble in the top level just like any other non-scoped plugins.

For example, if the plugin is `@myco/gulp-test-plugin` then you can access the plugin as shown in the following example:

```js
var scoped = require('gulp-load-plugins')({
scoped: true,
maintainScope: true,
});

scoped.myco.testPlugin();

var nonScoped = require('gulp-load-plugins')({
scoped: false,
maintainScope: false,
});

nonScoped.testPlugin();
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function(options) {
var camelizePluginName = options.camelize !== false;
var lazy = 'lazy' in options ? !!options.lazy : true;
var renameObj = options.rename || {};
var scoped = 'scoped' in options ? !!options.scoped : true;
var maintainScope = 'maintainScope' in options ? !!options.maintainScope : true;

logDebug('Debug enabled with options: ' + JSON.stringify(options));

Expand Down Expand Up @@ -143,7 +143,7 @@ module.exports = function(options) {
var fObject = finalObject;
if (scopeTest.test(name)) {
decomposition = scopeDecomposition.exec(name);
if (scoped) {
if (maintainScope) {
if (!fObject.hasOwnProperty(decomposition[1])) {
finalObject[decomposition[1]] = {};
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var commonTests = function(lazy) {
it('supports loading scopped package as a top-level reference', function() {
var x = gulpLoadPlugins({
lazy: lazy,
scoped: false,
maintainScope: false,
config: { dependencies: { '@myco/gulp-test-plugin': '1.0.0' } }
});

Expand Down

0 comments on commit f5db6b8

Please sign in to comment.