-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c712da2
Showing
12 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
env: | ||
browser: false | ||
node: true | ||
rules: | ||
no-extra-parens: 2 | ||
eqeqeq: 2 | ||
block-scoped-var: 2 | ||
quotes: | ||
- 2 | ||
- single |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"preset": "google", | ||
"maximumLineLength": 90 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
- '0.11' | ||
notifications: | ||
email: false | ||
after_script: | ||
- npm run-script coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Shinnosuke Watanabe | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# brace-expand-join | ||
|
||
[![Build Status](https://travis-ci.org/shinnn/node-brace-expand-join.svg?branch=master)](https://travis-ci.org/shinnn/node-brace-expand-join) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/57c2s0eqfq6ro65g)](https://ci.appveyor.com/project/ShinnosukeWatanabe/node-brace-expand-join) | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/node-brace-expand-join.svg)](https://coveralls.io/r/shinnn/node-brace-expand-join) | ||
[![Dependency Status](https://david-dm.org/shinnn/node-brace-expand-join#info=devDependencies.svg)](https://david-dm.org/shinnn/node-brace-expand-join) | ||
[![devDependency Status](https://david-dm.org/shinnn/node-brace-expand-join/dev-status.svg)](https://david-dm.org/shinnn/node-brace-expand-join#info=devDependencies) | ||
|
||
A [Node][node] module to join and normalize glob patterns considering [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) | ||
|
||
```javascript | ||
var braceExpandJoin = require('brace-expand-join'); | ||
|
||
braceExpandJoin('{a,b}', 'c'); //=> '{a/c,b/c}' | ||
braceExpandJoin('{a,b}', '{c,d}'); //=> '{a/c,a/d,b/cb/d}' | ||
braceExpandJoin('{a,b,c/d}', '../', 'e'); //=> '{e,c/e}' | ||
``` | ||
|
||
## Installation | ||
|
||
[![NPM version](https://badge.fury.io/js/brace-expand-join.svg)](https://www.npmjs.org/package/brace-expand-join) | ||
|
||
[Install with npm](https://www.npmjs.org/doc/cli/npm-install.html). (Make sure you have installed [Node][node]) | ||
|
||
``` | ||
npm install --save brace-expand-join | ||
``` | ||
|
||
## API | ||
|
||
```javascript | ||
var braceExpandJoin = require('brace-expand-join'); | ||
``` | ||
|
||
### braceExpandJoin(*pattern0* [, *pattern1*, ...]) | ||
|
||
*pattern0* [, *pattern1*, ...]: `String` | ||
Return: `String` | ||
|
||
It joins *patterns* like [path.join()](http://nodejs.org/api/path.html#path_path_join_path1_path2) expanding each part of brace expansions, and returns a new single glob pattern. | ||
|
||
```javascript | ||
braceExpandJoin('{,a{b,c}}', '{,d{e,f}}', '{,g{h,i}}') | ||
// => '{.,gh,gi,de,de/gh,de/gi,df,df/gh,df/gi,ab,ab/gh,ab/gi,ab/de,ab/de/gh,ab/de/gi,ab/df,ab/df/gh,ab/df/gi,ac,ac/gh,ac/gi,ac/de,ac/de/gh,ac/de/gi,ac/df,ac/df/gh,ac/df/gi}' | ||
``` | ||
|
||
## License | ||
|
||
Copyright (c) 2014 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
|
||
Licensed under [the MIT License](./LICENSE). | ||
|
||
[node]: http://nodejs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
init: | ||
- git config --global core.autocrlf input | ||
|
||
version: '{build}' | ||
|
||
environment: | ||
matrix: | ||
- nodejs_version: '0.10' | ||
- nodejs_version: '0.11' | ||
|
||
install: | ||
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) | ||
- npm install | ||
|
||
build: off | ||
|
||
test_script: | ||
- ps: node test.js | ||
- cmd: node test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*! | ||
* brace-expand-join | MIT (c) Shinnosuke Watanabe | ||
* https://github.com/shinnn/node-brace-expand-join | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var path = require('path'); | ||
|
||
var arrayUniq = require('array-uniq'); | ||
var braceExpand = require('minimatch').braceExpand; | ||
|
||
module.exports = function braceExpandJoin() { | ||
if (arguments.length === 0) { | ||
throw new Error('More than 1 glob pattern string required.'); | ||
} | ||
|
||
var joinedPatterns = [].slice.call(arguments) | ||
.map(function(pattern) { | ||
return braceExpand(pattern).map(function(pattern) { | ||
return path.normalize(pattern); | ||
}); | ||
}) | ||
.reduce(function(parentPatterns, childPatterns) { | ||
return parentPatterns.reduce(function(ret, parentPattern) { | ||
return ret.concat(childPatterns.map(function(childPattern) { | ||
return path.join(parentPattern, childPattern); | ||
})); | ||
}, []); | ||
}); | ||
|
||
joinedPatterns = arrayUniq(joinedPatterns); | ||
|
||
if (joinedPatterns.length > 1) { | ||
return '{' + joinedPatterns.join(',') + '}'; | ||
} | ||
|
||
return joinedPatterns[0]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "brace-expand-join", | ||
"version": "0.0.0", | ||
"description": "Join and normalize glob patterns considering brace expansion", | ||
"repository": "shinnn/node-brace-expand-join", | ||
"author": { | ||
"name": "Shinnosuke Watanabe", | ||
"url": "https://github.com/shinnn" | ||
}, | ||
"scripts": { | ||
"pretest": "eslint *.js & jscs *.js", | ||
"test": "node test.js | tap-spec", | ||
"coverage": "istanbul cover test.js", | ||
"coveralls": "${npm_package_scripts_coverage} && istanbul-coveralls" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/shinnn/node-brace-expand-join/blob/master/LICENSE" | ||
} | ||
], | ||
"files": [ | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"keywords": [ | ||
"path", | ||
"join", | ||
"glob", | ||
"normalize", | ||
"brace", | ||
"expand", | ||
"expansion" | ||
], | ||
"dependencies": { | ||
"array-uniq": "^1.0.0", | ||
"minimatch": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^0.8.1", | ||
"istanbul": "^0.3.2", | ||
"istanbul-coveralls": "^1.0.0", | ||
"jscs": "^1.6.1", | ||
"require-main": "^0.1.1", | ||
"tap-spec": "^0.2.1", | ||
"tape": "^2.14.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'); | ||
|
||
var braceExpandJoin = require('require-main')(); | ||
|
||
test('braceExpandJoin()', function(t) { | ||
t.plan(8); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('*', 'a'), '*/a', | ||
'should join patterns like path.join().' | ||
); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('a'), 'a', | ||
'should return a single pattern as it is when it has no brace expansion.' | ||
); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('a', '../b', '../', 'c'), 'c', | ||
'should join patterns considering parent directory reference.' | ||
); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('{a,b}', '*'), '{a/*,b/*}', | ||
'should join patterns considering brace expansion.' | ||
); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('{a,b/*/../c}', '../*'), '{*,b/*}', | ||
'should join patterns considering brace expansion and parent directory reference.' | ||
); | ||
|
||
t.strictEqual( | ||
braceExpandJoin('{a,a,b/../a}'), 'a', | ||
'should omit duplicated patterns.' | ||
); | ||
|
||
t.throws( | ||
braceExpandJoin.bind(null), /More than 1/, | ||
'should throw an error when it doesn\'t take any arguments.' | ||
); | ||
|
||
t.throws( | ||
braceExpandJoin.bind(null, ['a']), /glob pattern string required/, | ||
'should throw an error when it doesn\'t take any strings.' | ||
); | ||
|
||
t.end(); | ||
}); |