Skip to content

Commit

Permalink
cleanup #36
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 4, 2016
1 parent 77dde6d commit d49957a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ function assertPatternsInput(patterns) {
}
}

function castArray(value) {
return Array.isArray(value) ? value : [value];
}

function generateGlobTasks(patterns, opts) {
patterns = castArray(patterns);
patterns = [].concat(patterns);
assertPatternsInput(patterns);

var globTasks = [];
Expand Down Expand Up @@ -86,8 +82,7 @@ module.exports.sync = function (patterns, opts) {
module.exports.generateGlobTasks = generateGlobTasks;

module.exports.hasMagic = function (patterns, opts) {
patterns = castArray(patterns);
return patterns.some(function (pattern) {
return [].concat(patterns).some(function (pattern) {
return glob.hasMagic(pattern, opts);
});
};
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ Returns an array of objects in the format `{ pattern: string, opts: Object }`, w

Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.

### globby.hasMagic(patterns, [options])

Returns a `boolean` of whether there are any special glob characters in the `patterns`.

Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set.

#### patterns

Type: `string`, `Array`
Type: `string` `Array`

See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).

Expand All @@ -56,12 +62,6 @@ Type: `Object`

See the `node-glob` [options](https://github.com/isaacs/node-glob#options).

### globby.hasMagic(patterns, [options])

Returns `true` if there are any special glob characters in an array of patterns.

See `node-glob` hasMagic(https://github.com/isaacs/node-glob#globhasmagicpattern-options).


## Globbing patterns

Expand Down
3 changes: 0 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ test('expose generateGlobTasks', t => {

test('expose hasMagic', t => {
t.true(m.hasMagic('**'));
});

test('hasMagic handles multiple patterns', t => {
t.true(m.hasMagic(['**', 'path1', 'path2']));
t.false(m.hasMagic(['path1', 'path2']));
});
Expand Down

0 comments on commit d49957a

Please sign in to comment.