babel-schmooze-sprockets 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/bin/console +14 -0
  3. data/bin/export-external-helpers +3 -0
  4. data/bin/setup +6 -0
  5. data/bin/update-npm-deps +8 -0
  6. data/examples/myapp/Gemfile +4 -5
  7. data/examples/myapp/Gemfile.lock +69 -93
  8. data/examples/myapp/app/assets/javascripts/code/hello.es6 +5 -1
  9. data/examples/myapp/app/views/layouts/application.html.erb +1 -0
  10. data/examples/myapp/app/views/site/home.html.erb +0 -1
  11. data/lib/babel-schmooze-sprockets/babel_processor.rb +6 -4
  12. data/lib/babel-schmooze-sprockets/engine.rb +1 -4
  13. data/lib/babel-schmooze-sprockets/version.rb +1 -1
  14. data/node_modules/amdefine/package.json +8 -1
  15. data/node_modules/babel-core/node_modules/babel-runtime/package.json +9 -5
  16. data/node_modules/babel-core/node_modules/babel-traverse/.npmignore +3 -0
  17. data/node_modules/babel-core/node_modules/babel-traverse/README.md +1 -0
  18. data/node_modules/babel-core/node_modules/babel-traverse/lib/cache.js +20 -0
  19. data/node_modules/babel-core/node_modules/babel-traverse/lib/context.js +219 -0
  20. data/node_modules/babel-core/node_modules/babel-traverse/lib/hub.js +19 -0
  21. data/node_modules/babel-core/node_modules/babel-traverse/lib/index.js +250 -0
  22. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/ancestry.js +317 -0
  23. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/comments.js +55 -0
  24. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js +297 -0
  25. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/conversion.js +48 -0
  26. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/evaluation.js +406 -0
  27. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js +168 -0
  28. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/index.js +245 -0
  29. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/index.js +151 -0
  30. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferer-reference.js +225 -0
  31. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferers.js +198 -0
  32. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/introspection.js +518 -0
  33. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/hoister.js +166 -0
  34. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/removal-hooks.js +64 -0
  35. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/virtual-types.js +141 -0
  36. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/modification.js +293 -0
  37. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/removal.js +72 -0
  38. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/replacement.js +302 -0
  39. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/binding.js +105 -0
  40. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js +1222 -0
  41. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/lib/renamer.js +154 -0
  42. data/node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js +360 -0
  43. data/node_modules/babel-core/node_modules/babel-traverse/package.json +107 -0
  44. data/node_modules/babel-core/node_modules/core-js/package.json +20 -2
  45. data/node_modules/babel-core/package.json +31 -24
  46. data/node_modules/babel-generator/lib/buffer.js +69 -70
  47. data/node_modules/babel-generator/lib/generators/base.js +16 -12
  48. data/node_modules/babel-generator/lib/generators/classes.js +28 -19
  49. data/node_modules/babel-generator/lib/generators/expressions.js +76 -99
  50. data/node_modules/babel-generator/lib/generators/flow.js +178 -119
  51. data/node_modules/babel-generator/lib/generators/jsx.js +38 -29
  52. data/node_modules/babel-generator/lib/generators/methods.js +34 -25
  53. data/node_modules/babel-generator/lib/generators/modules.js +67 -40
  54. data/node_modules/babel-generator/lib/generators/statements.js +93 -76
  55. data/node_modules/babel-generator/lib/generators/template-literals.js +12 -11
  56. data/node_modules/babel-generator/lib/generators/types.js +56 -49
  57. data/node_modules/babel-generator/lib/index.js +52 -39
  58. data/node_modules/babel-generator/lib/node/index.js +12 -18
  59. data/node_modules/babel-generator/lib/node/parentheses.js +23 -27
  60. data/node_modules/babel-generator/lib/node/whitespace.js +20 -26
  61. data/node_modules/babel-generator/lib/position.js +5 -5
  62. data/node_modules/babel-generator/lib/printer.js +52 -81
  63. data/node_modules/babel-generator/lib/source-map.js +9 -11
  64. data/node_modules/babel-generator/lib/whitespace.js +13 -13
  65. data/node_modules/babel-generator/node_modules/babel-runtime/package.json +19 -6
  66. data/node_modules/babel-generator/node_modules/babel-types/.npmignore +3 -0
  67. data/node_modules/babel-generator/node_modules/babel-types/README.md +1141 -0
  68. data/node_modules/babel-generator/node_modules/babel-types/lib/constants.js +40 -0
  69. data/node_modules/babel-generator/node_modules/babel-types/lib/converters.js +378 -0
  70. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/core.js +704 -0
  71. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/es2015.js +354 -0
  72. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/experimental.js +85 -0
  73. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/flow.js +319 -0
  74. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/index.js +247 -0
  75. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/init.js +15 -0
  76. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/jsx.js +137 -0
  77. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/misc.js +21 -0
  78. data/node_modules/babel-generator/node_modules/babel-types/lib/flow.js +129 -0
  79. data/node_modules/babel-generator/node_modules/babel-types/lib/index.js +848 -0
  80. data/node_modules/babel-generator/node_modules/babel-types/lib/react.js +83 -0
  81. data/node_modules/babel-generator/node_modules/babel-types/lib/retrievers.js +123 -0
  82. data/node_modules/babel-generator/node_modules/babel-types/lib/validators.js +276 -0
  83. data/node_modules/babel-generator/node_modules/babel-types/package.json +103 -0
  84. data/node_modules/babel-generator/node_modules/core-js/package.json +10 -5
  85. data/node_modules/babel-generator/package.json +19 -16
  86. data/node_modules/babel-helpers/node_modules/babel-runtime/package.json +19 -3
  87. data/node_modules/babel-helpers/node_modules/core-js/package.json +20 -4
  88. data/node_modules/babel-helpers/package.json +8 -1
  89. data/node_modules/babel-register/node_modules/babel-runtime/package.json +19 -3
  90. data/node_modules/babel-register/node_modules/core-js/package.json +20 -4
  91. data/node_modules/babel-register/package.json +8 -1
  92. data/node_modules/balanced-match/package.json +8 -1
  93. data/node_modules/brace-expansion/package.json +19 -12
  94. data/node_modules/concat-map/package.json +9 -2
  95. data/node_modules/convert-source-map/package.json +8 -1
  96. data/node_modules/detect-indent/package.json +8 -1
  97. data/node_modules/get-stdin/package.json +8 -1
  98. data/node_modules/home-or-tmp/package.json +9 -2
  99. data/node_modules/is-finite/package.json +8 -2
  100. data/node_modules/json5/package.json +8 -1
  101. data/node_modules/minimatch/README.md +2 -9
  102. data/node_modules/minimatch/minimatch.js +15 -3
  103. data/node_modules/minimatch/package.json +29 -21
  104. data/node_modules/minimist/package.json +8 -1
  105. data/node_modules/mkdirp/node_modules/minimist/package.json +8 -1
  106. data/node_modules/mkdirp/package.json +8 -1
  107. data/node_modules/number-is-nan/package.json +8 -1
  108. data/node_modules/os-tmpdir/package.json +8 -1
  109. data/node_modules/path-exists/package.json +8 -1
  110. data/node_modules/path-is-absolute/package.json +8 -1
  111. data/node_modules/repeating/package.json +15 -11
  112. data/node_modules/shebang-regex/package.json +8 -1
  113. data/node_modules/slash/package.json +8 -1
  114. data/node_modules/source-map-support/node_modules/source-map/package.json +8 -1
  115. data/node_modules/source-map-support/package.json +8 -1
  116. data/node_modules/source-map/package.json +8 -1
  117. data/node_modules/user-home/package.json +8 -1
  118. data/package.json +1 -1
  119. metadata +54 -6
  120. data/node_modules/brace-expansion/.npmignore +0 -3
  121. data/node_modules/brace-expansion/example.js +0 -8
  122. data/node_modules/minimatch/browser.js +0 -1159
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "shebang-regex@^1.0.0",
4
+ {
5
+ "name": "shebang-regex",
6
+ "raw": "shebang-regex@^1.0.0",
7
+ "rawSpec": "^1.0.0",
8
+ "scope": null,
9
+ "spec": ">=1.0.0 <2.0.0",
10
+ "type": "range"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core"
6
13
  ]
7
14
  ],
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "slash@^1.0.0",
4
+ {
5
+ "name": "slash",
6
+ "raw": "slash@^1.0.0",
7
+ "rawSpec": "^1.0.0",
8
+ "scope": null,
9
+ "spec": ">=1.0.0 <2.0.0",
10
+ "type": "range"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core"
6
13
  ]
7
14
  ],
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "source-map@0.1.32",
4
+ {
5
+ "name": "source-map",
6
+ "raw": "source-map@0.1.32",
7
+ "rawSpec": "0.1.32",
8
+ "scope": null,
9
+ "spec": "0.1.32",
10
+ "type": "version"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/source-map-support"
6
13
  ]
7
14
  ],
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "source-map-support@^0.2.10",
4
+ {
5
+ "name": "source-map-support",
6
+ "raw": "source-map-support@^0.2.10",
7
+ "rawSpec": "^0.2.10",
8
+ "scope": null,
9
+ "spec": ">=0.2.10 <0.3.0",
10
+ "type": "range"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-register"
6
13
  ]
7
14
  ],
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "source-map@^0.5.0",
4
+ {
5
+ "name": "source-map",
6
+ "raw": "source-map@^0.5.0",
7
+ "rawSpec": "^0.5.0",
8
+ "scope": null,
9
+ "spec": ">=0.5.0 <0.6.0",
10
+ "type": "range"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core"
6
13
  ]
7
14
  ],
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "user-home@^1.1.1",
4
+ {
5
+ "name": "user-home",
6
+ "raw": "user-home@^1.1.1",
7
+ "rawSpec": "^1.1.1",
8
+ "scope": null,
9
+ "spec": ">=1.1.1 <2.0.0",
10
+ "type": "range"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/home-or-tmp"
6
13
  ]
7
14
  ],
@@ -4,7 +4,7 @@
4
4
  "repository": "https://github.com/fnando/babel-schmooze-sprockets.git",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "babel-core": "^6.9.1",
7
+ "babel-core": "^6.10.4",
8
8
  "babel-plugin-add-module-exports": "^0.2.1",
9
9
  "babel-plugin-external-helpers": "^6.8.0",
10
10
  "babel-plugin-transform-async-to-generator": "^6.8.0",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babel-schmooze-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: schmooze
@@ -127,6 +127,10 @@ files:
127
127
  - app/assets/javascripts/babel/external-helpers.js
128
128
  - app/assets/javascripts/babel/polyfill.js
129
129
  - babel-schmooze-sprockets.gemspec
130
+ - bin/console
131
+ - bin/export-external-helpers
132
+ - bin/setup
133
+ - bin/update-npm-deps
130
134
  - examples/myapp/.gitignore
131
135
  - examples/myapp/Gemfile
132
136
  - examples/myapp/Gemfile.lock
@@ -2048,6 +2052,34 @@ files:
2048
2052
  - node_modules/babel-core/node_modules/babel-runtime/helpers/typeof.js
2049
2053
  - node_modules/babel-core/node_modules/babel-runtime/package.json
2050
2054
  - node_modules/babel-core/node_modules/babel-runtime/regenerator/index.js
2055
+ - node_modules/babel-core/node_modules/babel-traverse/.npmignore
2056
+ - node_modules/babel-core/node_modules/babel-traverse/README.md
2057
+ - node_modules/babel-core/node_modules/babel-traverse/lib/cache.js
2058
+ - node_modules/babel-core/node_modules/babel-traverse/lib/context.js
2059
+ - node_modules/babel-core/node_modules/babel-traverse/lib/hub.js
2060
+ - node_modules/babel-core/node_modules/babel-traverse/lib/index.js
2061
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/ancestry.js
2062
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/comments.js
2063
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js
2064
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/conversion.js
2065
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/evaluation.js
2066
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js
2067
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/index.js
2068
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/index.js
2069
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferer-reference.js
2070
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferers.js
2071
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/introspection.js
2072
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/hoister.js
2073
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/removal-hooks.js
2074
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/virtual-types.js
2075
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/modification.js
2076
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/removal.js
2077
+ - node_modules/babel-core/node_modules/babel-traverse/lib/path/replacement.js
2078
+ - node_modules/babel-core/node_modules/babel-traverse/lib/scope/binding.js
2079
+ - node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js
2080
+ - node_modules/babel-core/node_modules/babel-traverse/lib/scope/lib/renamer.js
2081
+ - node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js
2082
+ - node_modules/babel-core/node_modules/babel-traverse/package.json
2051
2083
  - node_modules/babel-core/node_modules/core-js/CHANGELOG.md
2052
2084
  - node_modules/babel-core/node_modules/core-js/Gruntfile.js
2053
2085
  - node_modules/babel-core/node_modules/core-js/LICENSE
@@ -3643,6 +3675,24 @@ files:
3643
3675
  - node_modules/babel-generator/node_modules/babel-runtime/helpers/typeof.js
3644
3676
  - node_modules/babel-generator/node_modules/babel-runtime/package.json
3645
3677
  - node_modules/babel-generator/node_modules/babel-runtime/regenerator/index.js
3678
+ - node_modules/babel-generator/node_modules/babel-types/.npmignore
3679
+ - node_modules/babel-generator/node_modules/babel-types/README.md
3680
+ - node_modules/babel-generator/node_modules/babel-types/lib/constants.js
3681
+ - node_modules/babel-generator/node_modules/babel-types/lib/converters.js
3682
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/core.js
3683
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/es2015.js
3684
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/experimental.js
3685
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/flow.js
3686
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/index.js
3687
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/init.js
3688
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/jsx.js
3689
+ - node_modules/babel-generator/node_modules/babel-types/lib/definitions/misc.js
3690
+ - node_modules/babel-generator/node_modules/babel-types/lib/flow.js
3691
+ - node_modules/babel-generator/node_modules/babel-types/lib/index.js
3692
+ - node_modules/babel-generator/node_modules/babel-types/lib/react.js
3693
+ - node_modules/babel-generator/node_modules/babel-types/lib/retrievers.js
3694
+ - node_modules/babel-generator/node_modules/babel-types/lib/validators.js
3695
+ - node_modules/babel-generator/node_modules/babel-types/package.json
3646
3696
  - node_modules/babel-generator/node_modules/core-js/CHANGELOG.md
3647
3697
  - node_modules/babel-generator/node_modules/core-js/Gruntfile.js
3648
3698
  - node_modules/babel-generator/node_modules/core-js/LICENSE
@@ -77877,9 +77927,7 @@ files:
77877
77927
  - node_modules/balanced-match/README.md
77878
77928
  - node_modules/balanced-match/index.js
77879
77929
  - node_modules/balanced-match/package.json
77880
- - node_modules/brace-expansion/.npmignore
77881
77930
  - node_modules/brace-expansion/README.md
77882
- - node_modules/brace-expansion/example.js
77883
77931
  - node_modules/brace-expansion/index.js
77884
77932
  - node_modules/brace-expansion/package.json
77885
77933
  - node_modules/chalk/index.js
@@ -79962,7 +80010,6 @@ files:
79962
80010
  - node_modules/loose-envify/replace.js
79963
80011
  - node_modules/minimatch/LICENSE
79964
80012
  - node_modules/minimatch/README.md
79965
- - node_modules/minimatch/browser.js
79966
80013
  - node_modules/minimatch/minimatch.js
79967
80014
  - node_modules/minimatch/package.json
79968
80015
  - node_modules/minimist/.travis.yml
@@ -80203,8 +80250,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80203
80250
  version: '0'
80204
80251
  requirements: []
80205
80252
  rubyforge_project:
80206
- rubygems_version: 2.5.1
80253
+ rubygems_version: 2.6.4
80207
80254
  signing_key:
80208
80255
  specification_version: 4
80209
80256
  summary: Add Babel support to sprockets using Schmooze.
80210
80257
  test_files: []
80258
+ has_rdoc:
@@ -1,3 +0,0 @@
1
- test
2
- .gitignore
3
- .travis.yml
@@ -1,8 +0,0 @@
1
- var expand = require('./');
2
-
3
- console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html'));
4
- console.log(expand('http://www.numericals.com/file{1..100..10}.txt'));
5
- console.log(expand('http://www.letters.com/file{a..z..2}.txt'));
6
- console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}'));
7
- console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}'));
8
-
@@ -1,1159 +0,0 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.minimatch = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- module.exports = minimatch
3
- minimatch.Minimatch = Minimatch
4
-
5
- var path = { sep: '/' }
6
- try {
7
- path = require('path')
8
- } catch (er) {}
9
-
10
- var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
11
- var expand = require('brace-expansion')
12
-
13
- // any single thing other than /
14
- // don't need to escape / when using new RegExp()
15
- var qmark = '[^/]'
16
-
17
- // * => any number of characters
18
- var star = qmark + '*?'
19
-
20
- // ** when dots are allowed. Anything goes, except .. and .
21
- // not (^ or / followed by one or two dots followed by $ or /),
22
- // followed by anything, any number of times.
23
- var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
24
-
25
- // not a ^ or / followed by a dot,
26
- // followed by anything, any number of times.
27
- var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
28
-
29
- // characters that need to be escaped in RegExp.
30
- var reSpecials = charSet('().*{}+?[]^$\\!')
31
-
32
- // "abc" -> { a:true, b:true, c:true }
33
- function charSet (s) {
34
- return s.split('').reduce(function (set, c) {
35
- set[c] = true
36
- return set
37
- }, {})
38
- }
39
-
40
- // normalizes slashes.
41
- var slashSplit = /\/+/
42
-
43
- minimatch.filter = filter
44
- function filter (pattern, options) {
45
- options = options || {}
46
- return function (p, i, list) {
47
- return minimatch(p, pattern, options)
48
- }
49
- }
50
-
51
- function ext (a, b) {
52
- a = a || {}
53
- b = b || {}
54
- var t = {}
55
- Object.keys(b).forEach(function (k) {
56
- t[k] = b[k]
57
- })
58
- Object.keys(a).forEach(function (k) {
59
- t[k] = a[k]
60
- })
61
- return t
62
- }
63
-
64
- minimatch.defaults = function (def) {
65
- if (!def || !Object.keys(def).length) return minimatch
66
-
67
- var orig = minimatch
68
-
69
- var m = function minimatch (p, pattern, options) {
70
- return orig.minimatch(p, pattern, ext(def, options))
71
- }
72
-
73
- m.Minimatch = function Minimatch (pattern, options) {
74
- return new orig.Minimatch(pattern, ext(def, options))
75
- }
76
-
77
- return m
78
- }
79
-
80
- Minimatch.defaults = function (def) {
81
- if (!def || !Object.keys(def).length) return Minimatch
82
- return minimatch.defaults(def).Minimatch
83
- }
84
-
85
- function minimatch (p, pattern, options) {
86
- if (typeof pattern !== 'string') {
87
- throw new TypeError('glob pattern string required')
88
- }
89
-
90
- if (!options) options = {}
91
-
92
- // shortcut: comments match nothing.
93
- if (!options.nocomment && pattern.charAt(0) === '#') {
94
- return false
95
- }
96
-
97
- // "" only matches ""
98
- if (pattern.trim() === '') return p === ''
99
-
100
- return new Minimatch(pattern, options).match(p)
101
- }
102
-
103
- function Minimatch (pattern, options) {
104
- if (!(this instanceof Minimatch)) {
105
- return new Minimatch(pattern, options)
106
- }
107
-
108
- if (typeof pattern !== 'string') {
109
- throw new TypeError('glob pattern string required')
110
- }
111
-
112
- if (!options) options = {}
113
- pattern = pattern.trim()
114
-
115
- // windows support: need to use /, not \
116
- if (path.sep !== '/') {
117
- pattern = pattern.split(path.sep).join('/')
118
- }
119
-
120
- this.options = options
121
- this.set = []
122
- this.pattern = pattern
123
- this.regexp = null
124
- this.negate = false
125
- this.comment = false
126
- this.empty = false
127
-
128
- // make the set of regexps etc.
129
- this.make()
130
- }
131
-
132
- Minimatch.prototype.debug = function () {}
133
-
134
- Minimatch.prototype.make = make
135
- function make () {
136
- // don't do it more than once.
137
- if (this._made) return
138
-
139
- var pattern = this.pattern
140
- var options = this.options
141
-
142
- // empty patterns and comments match nothing.
143
- if (!options.nocomment && pattern.charAt(0) === '#') {
144
- this.comment = true
145
- return
146
- }
147
- if (!pattern) {
148
- this.empty = true
149
- return
150
- }
151
-
152
- // step 1: figure out negation, etc.
153
- this.parseNegate()
154
-
155
- // step 2: expand braces
156
- var set = this.globSet = this.braceExpand()
157
-
158
- if (options.debug) this.debug = console.error
159
-
160
- this.debug(this.pattern, set)
161
-
162
- // step 3: now we have a set, so turn each one into a series of path-portion
163
- // matching patterns.
164
- // These will be regexps, except in the case of "**", which is
165
- // set to the GLOBSTAR object for globstar behavior,
166
- // and will not contain any / characters
167
- set = this.globParts = set.map(function (s) {
168
- return s.split(slashSplit)
169
- })
170
-
171
- this.debug(this.pattern, set)
172
-
173
- // glob --> regexps
174
- set = set.map(function (s, si, set) {
175
- return s.map(this.parse, this)
176
- }, this)
177
-
178
- this.debug(this.pattern, set)
179
-
180
- // filter out everything that didn't compile properly.
181
- set = set.filter(function (s) {
182
- return s.indexOf(false) === -1
183
- })
184
-
185
- this.debug(this.pattern, set)
186
-
187
- this.set = set
188
- }
189
-
190
- Minimatch.prototype.parseNegate = parseNegate
191
- function parseNegate () {
192
- var pattern = this.pattern
193
- var negate = false
194
- var options = this.options
195
- var negateOffset = 0
196
-
197
- if (options.nonegate) return
198
-
199
- for (var i = 0, l = pattern.length
200
- ; i < l && pattern.charAt(i) === '!'
201
- ; i++) {
202
- negate = !negate
203
- negateOffset++
204
- }
205
-
206
- if (negateOffset) this.pattern = pattern.substr(negateOffset)
207
- this.negate = negate
208
- }
209
-
210
- // Brace expansion:
211
- // a{b,c}d -> abd acd
212
- // a{b,}c -> abc ac
213
- // a{0..3}d -> a0d a1d a2d a3d
214
- // a{b,c{d,e}f}g -> abg acdfg acefg
215
- // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
216
- //
217
- // Invalid sets are not expanded.
218
- // a{2..}b -> a{2..}b
219
- // a{b}c -> a{b}c
220
- minimatch.braceExpand = function (pattern, options) {
221
- return braceExpand(pattern, options)
222
- }
223
-
224
- Minimatch.prototype.braceExpand = braceExpand
225
-
226
- function braceExpand (pattern, options) {
227
- if (!options) {
228
- if (this instanceof Minimatch) {
229
- options = this.options
230
- } else {
231
- options = {}
232
- }
233
- }
234
-
235
- pattern = typeof pattern === 'undefined'
236
- ? this.pattern : pattern
237
-
238
- if (typeof pattern === 'undefined') {
239
- throw new Error('undefined pattern')
240
- }
241
-
242
- if (options.nobrace ||
243
- !pattern.match(/\{.*\}/)) {
244
- // shortcut. no need to expand.
245
- return [pattern]
246
- }
247
-
248
- return expand(pattern)
249
- }
250
-
251
- // parse a component of the expanded set.
252
- // At this point, no pattern may contain "/" in it
253
- // so we're going to return a 2d array, where each entry is the full
254
- // pattern, split on '/', and then turned into a regular expression.
255
- // A regexp is made at the end which joins each array with an
256
- // escaped /, and another full one which joins each regexp with |.
257
- //
258
- // Following the lead of Bash 4.1, note that "**" only has special meaning
259
- // when it is the *only* thing in a path portion. Otherwise, any series
260
- // of * is equivalent to a single *. Globstar behavior is enabled by
261
- // default, and can be disabled by setting options.noglobstar.
262
- Minimatch.prototype.parse = parse
263
- var SUBPARSE = {}
264
- function parse (pattern, isSub) {
265
- var options = this.options
266
-
267
- // shortcuts
268
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
269
- if (pattern === '') return ''
270
-
271
- var re = ''
272
- var hasMagic = !!options.nocase
273
- var escaping = false
274
- // ? => one single character
275
- var patternListStack = []
276
- var negativeLists = []
277
- var plType
278
- var stateChar
279
- var inClass = false
280
- var reClassStart = -1
281
- var classStart = -1
282
- // . and .. never match anything that doesn't start with .,
283
- // even when options.dot is set.
284
- var patternStart = pattern.charAt(0) === '.' ? '' // anything
285
- // not (start or / followed by . or .. followed by / or end)
286
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
287
- : '(?!\\.)'
288
- var self = this
289
-
290
- function clearStateChar () {
291
- if (stateChar) {
292
- // we had some state-tracking character
293
- // that wasn't consumed by this pass.
294
- switch (stateChar) {
295
- case '*':
296
- re += star
297
- hasMagic = true
298
- break
299
- case '?':
300
- re += qmark
301
- hasMagic = true
302
- break
303
- default:
304
- re += '\\' + stateChar
305
- break
306
- }
307
- self.debug('clearStateChar %j %j', stateChar, re)
308
- stateChar = false
309
- }
310
- }
311
-
312
- for (var i = 0, len = pattern.length, c
313
- ; (i < len) && (c = pattern.charAt(i))
314
- ; i++) {
315
- this.debug('%s\t%s %s %j', pattern, i, re, c)
316
-
317
- // skip over any that are escaped.
318
- if (escaping && reSpecials[c]) {
319
- re += '\\' + c
320
- escaping = false
321
- continue
322
- }
323
-
324
- switch (c) {
325
- case '/':
326
- // completely not allowed, even escaped.
327
- // Should already be path-split by now.
328
- return false
329
-
330
- case '\\':
331
- clearStateChar()
332
- escaping = true
333
- continue
334
-
335
- // the various stateChar values
336
- // for the "extglob" stuff.
337
- case '?':
338
- case '*':
339
- case '+':
340
- case '@':
341
- case '!':
342
- this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
343
-
344
- // all of those are literals inside a class, except that
345
- // the glob [!a] means [^a] in regexp
346
- if (inClass) {
347
- this.debug(' in class')
348
- if (c === '!' && i === classStart + 1) c = '^'
349
- re += c
350
- continue
351
- }
352
-
353
- // if we already have a stateChar, then it means
354
- // that there was something like ** or +? in there.
355
- // Handle the stateChar, then proceed with this one.
356
- self.debug('call clearStateChar %j', stateChar)
357
- clearStateChar()
358
- stateChar = c
359
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
360
- // just clear the statechar *now*, rather than even diving into
361
- // the patternList stuff.
362
- if (options.noext) clearStateChar()
363
- continue
364
-
365
- case '(':
366
- if (inClass) {
367
- re += '('
368
- continue
369
- }
370
-
371
- if (!stateChar) {
372
- re += '\\('
373
- continue
374
- }
375
-
376
- plType = stateChar
377
- patternListStack.push({
378
- type: plType,
379
- start: i - 1,
380
- reStart: re.length
381
- })
382
- // negation is (?:(?!js)[^/]*)
383
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
384
- this.debug('plType %j %j', stateChar, re)
385
- stateChar = false
386
- continue
387
-
388
- case ')':
389
- if (inClass || !patternListStack.length) {
390
- re += '\\)'
391
- continue
392
- }
393
-
394
- clearStateChar()
395
- hasMagic = true
396
- re += ')'
397
- var pl = patternListStack.pop()
398
- plType = pl.type
399
- // negation is (?:(?!js)[^/]*)
400
- // The others are (?:<pattern>)<type>
401
- switch (plType) {
402
- case '!':
403
- negativeLists.push(pl)
404
- re += ')[^/]*?)'
405
- pl.reEnd = re.length
406
- break
407
- case '?':
408
- case '+':
409
- case '*':
410
- re += plType
411
- break
412
- case '@': break // the default anyway
413
- }
414
- continue
415
-
416
- case '|':
417
- if (inClass || !patternListStack.length || escaping) {
418
- re += '\\|'
419
- escaping = false
420
- continue
421
- }
422
-
423
- clearStateChar()
424
- re += '|'
425
- continue
426
-
427
- // these are mostly the same in regexp and glob
428
- case '[':
429
- // swallow any state-tracking char before the [
430
- clearStateChar()
431
-
432
- if (inClass) {
433
- re += '\\' + c
434
- continue
435
- }
436
-
437
- inClass = true
438
- classStart = i
439
- reClassStart = re.length
440
- re += c
441
- continue
442
-
443
- case ']':
444
- // a right bracket shall lose its special
445
- // meaning and represent itself in
446
- // a bracket expression if it occurs
447
- // first in the list. -- POSIX.2 2.8.3.2
448
- if (i === classStart + 1 || !inClass) {
449
- re += '\\' + c
450
- escaping = false
451
- continue
452
- }
453
-
454
- // handle the case where we left a class open.
455
- // "[z-a]" is valid, equivalent to "\[z-a\]"
456
- if (inClass) {
457
- // split where the last [ was, make sure we don't have
458
- // an invalid re. if so, re-walk the contents of the
459
- // would-be class to re-translate any characters that
460
- // were passed through as-is
461
- // TODO: It would probably be faster to determine this
462
- // without a try/catch and a new RegExp, but it's tricky
463
- // to do safely. For now, this is safe and works.
464
- var cs = pattern.substring(classStart + 1, i)
465
- try {
466
- RegExp('[' + cs + ']')
467
- } catch (er) {
468
- // not a valid class!
469
- var sp = this.parse(cs, SUBPARSE)
470
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
471
- hasMagic = hasMagic || sp[1]
472
- inClass = false
473
- continue
474
- }
475
- }
476
-
477
- // finish up the class.
478
- hasMagic = true
479
- inClass = false
480
- re += c
481
- continue
482
-
483
- default:
484
- // swallow any state char that wasn't consumed
485
- clearStateChar()
486
-
487
- if (escaping) {
488
- // no need
489
- escaping = false
490
- } else if (reSpecials[c]
491
- && !(c === '^' && inClass)) {
492
- re += '\\'
493
- }
494
-
495
- re += c
496
-
497
- } // switch
498
- } // for
499
-
500
- // handle the case where we left a class open.
501
- // "[abc" is valid, equivalent to "\[abc"
502
- if (inClass) {
503
- // split where the last [ was, and escape it
504
- // this is a huge pita. We now have to re-walk
505
- // the contents of the would-be class to re-translate
506
- // any characters that were passed through as-is
507
- cs = pattern.substr(classStart + 1)
508
- sp = this.parse(cs, SUBPARSE)
509
- re = re.substr(0, reClassStart) + '\\[' + sp[0]
510
- hasMagic = hasMagic || sp[1]
511
- }
512
-
513
- // handle the case where we had a +( thing at the *end*
514
- // of the pattern.
515
- // each pattern list stack adds 3 chars, and we need to go through
516
- // and escape any | chars that were passed through as-is for the regexp.
517
- // Go through and escape them, taking care not to double-escape any
518
- // | chars that were already escaped.
519
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
520
- var tail = re.slice(pl.reStart + 3)
521
- // maybe some even number of \, then maybe 1 \, followed by a |
522
- tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
523
- if (!$2) {
524
- // the | isn't already escaped, so escape it.
525
- $2 = '\\'
526
- }
527
-
528
- // need to escape all those slashes *again*, without escaping the
529
- // one that we need for escaping the | character. As it works out,
530
- // escaping an even number of slashes can be done by simply repeating
531
- // it exactly after itself. That's why this trick works.
532
- //
533
- // I am sorry that you have to see this.
534
- return $1 + $1 + $2 + '|'
535
- })
536
-
537
- this.debug('tail=%j\n %s', tail, tail)
538
- var t = pl.type === '*' ? star
539
- : pl.type === '?' ? qmark
540
- : '\\' + pl.type
541
-
542
- hasMagic = true
543
- re = re.slice(0, pl.reStart) + t + '\\(' + tail
544
- }
545
-
546
- // handle trailing things that only matter at the very end.
547
- clearStateChar()
548
- if (escaping) {
549
- // trailing \\
550
- re += '\\\\'
551
- }
552
-
553
- // only need to apply the nodot start if the re starts with
554
- // something that could conceivably capture a dot
555
- var addPatternStart = false
556
- switch (re.charAt(0)) {
557
- case '.':
558
- case '[':
559
- case '(': addPatternStart = true
560
- }
561
-
562
- // Hack to work around lack of negative lookbehind in JS
563
- // A pattern like: *.!(x).!(y|z) needs to ensure that a name
564
- // like 'a.xyz.yz' doesn't match. So, the first negative
565
- // lookahead, has to look ALL the way ahead, to the end of
566
- // the pattern.
567
- for (var n = negativeLists.length - 1; n > -1; n--) {
568
- var nl = negativeLists[n]
569
-
570
- var nlBefore = re.slice(0, nl.reStart)
571
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
572
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
573
- var nlAfter = re.slice(nl.reEnd)
574
-
575
- nlLast += nlAfter
576
-
577
- // Handle nested stuff like *(*.js|!(*.json)), where open parens
578
- // mean that we should *not* include the ) in the bit that is considered
579
- // "after" the negated section.
580
- var openParensBefore = nlBefore.split('(').length - 1
581
- var cleanAfter = nlAfter
582
- for (i = 0; i < openParensBefore; i++) {
583
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
584
- }
585
- nlAfter = cleanAfter
586
-
587
- var dollar = ''
588
- if (nlAfter === '' && isSub !== SUBPARSE) {
589
- dollar = '$'
590
- }
591
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
592
- re = newRe
593
- }
594
-
595
- // if the re is not "" at this point, then we need to make sure
596
- // it doesn't match against an empty path part.
597
- // Otherwise a/* will match a/, which it should not.
598
- if (re !== '' && hasMagic) {
599
- re = '(?=.)' + re
600
- }
601
-
602
- if (addPatternStart) {
603
- re = patternStart + re
604
- }
605
-
606
- // parsing just a piece of a larger pattern.
607
- if (isSub === SUBPARSE) {
608
- return [re, hasMagic]
609
- }
610
-
611
- // skip the regexp for non-magical patterns
612
- // unescape anything in it, though, so that it'll be
613
- // an exact match against a file etc.
614
- if (!hasMagic) {
615
- return globUnescape(pattern)
616
- }
617
-
618
- var flags = options.nocase ? 'i' : ''
619
- var regExp = new RegExp('^' + re + '$', flags)
620
-
621
- regExp._glob = pattern
622
- regExp._src = re
623
-
624
- return regExp
625
- }
626
-
627
- minimatch.makeRe = function (pattern, options) {
628
- return new Minimatch(pattern, options || {}).makeRe()
629
- }
630
-
631
- Minimatch.prototype.makeRe = makeRe
632
- function makeRe () {
633
- if (this.regexp || this.regexp === false) return this.regexp
634
-
635
- // at this point, this.set is a 2d array of partial
636
- // pattern strings, or "**".
637
- //
638
- // It's better to use .match(). This function shouldn't
639
- // be used, really, but it's pretty convenient sometimes,
640
- // when you just want to work with a regex.
641
- var set = this.set
642
-
643
- if (!set.length) {
644
- this.regexp = false
645
- return this.regexp
646
- }
647
- var options = this.options
648
-
649
- var twoStar = options.noglobstar ? star
650
- : options.dot ? twoStarDot
651
- : twoStarNoDot
652
- var flags = options.nocase ? 'i' : ''
653
-
654
- var re = set.map(function (pattern) {
655
- return pattern.map(function (p) {
656
- return (p === GLOBSTAR) ? twoStar
657
- : (typeof p === 'string') ? regExpEscape(p)
658
- : p._src
659
- }).join('\\\/')
660
- }).join('|')
661
-
662
- // must match entire pattern
663
- // ending in a * or ** will make it less strict.
664
- re = '^(?:' + re + ')$'
665
-
666
- // can match anything, as long as it's not this.
667
- if (this.negate) re = '^(?!' + re + ').*$'
668
-
669
- try {
670
- this.regexp = new RegExp(re, flags)
671
- } catch (ex) {
672
- this.regexp = false
673
- }
674
- return this.regexp
675
- }
676
-
677
- minimatch.match = function (list, pattern, options) {
678
- options = options || {}
679
- var mm = new Minimatch(pattern, options)
680
- list = list.filter(function (f) {
681
- return mm.match(f)
682
- })
683
- if (mm.options.nonull && !list.length) {
684
- list.push(pattern)
685
- }
686
- return list
687
- }
688
-
689
- Minimatch.prototype.match = match
690
- function match (f, partial) {
691
- this.debug('match', f, this.pattern)
692
- // short-circuit in the case of busted things.
693
- // comments, etc.
694
- if (this.comment) return false
695
- if (this.empty) return f === ''
696
-
697
- if (f === '/' && partial) return true
698
-
699
- var options = this.options
700
-
701
- // windows: need to use /, not \
702
- if (path.sep !== '/') {
703
- f = f.split(path.sep).join('/')
704
- }
705
-
706
- // treat the test path as a set of pathparts.
707
- f = f.split(slashSplit)
708
- this.debug(this.pattern, 'split', f)
709
-
710
- // just ONE of the pattern sets in this.set needs to match
711
- // in order for it to be valid. If negating, then just one
712
- // match means that we have failed.
713
- // Either way, return on the first hit.
714
-
715
- var set = this.set
716
- this.debug(this.pattern, 'set', set)
717
-
718
- // Find the basename of the path by looking for the last non-empty segment
719
- var filename
720
- var i
721
- for (i = f.length - 1; i >= 0; i--) {
722
- filename = f[i]
723
- if (filename) break
724
- }
725
-
726
- for (i = 0; i < set.length; i++) {
727
- var pattern = set[i]
728
- var file = f
729
- if (options.matchBase && pattern.length === 1) {
730
- file = [filename]
731
- }
732
- var hit = this.matchOne(file, pattern, partial)
733
- if (hit) {
734
- if (options.flipNegate) return true
735
- return !this.negate
736
- }
737
- }
738
-
739
- // didn't get any hits. this is success if it's a negative
740
- // pattern, failure otherwise.
741
- if (options.flipNegate) return false
742
- return this.negate
743
- }
744
-
745
- // set partial to true to test if, for example,
746
- // "/a/b" matches the start of "/*/b/*/d"
747
- // Partial means, if you run out of file before you run
748
- // out of pattern, then that's fine, as long as all
749
- // the parts match.
750
- Minimatch.prototype.matchOne = function (file, pattern, partial) {
751
- var options = this.options
752
-
753
- this.debug('matchOne',
754
- { 'this': this, file: file, pattern: pattern })
755
-
756
- this.debug('matchOne', file.length, pattern.length)
757
-
758
- for (var fi = 0,
759
- pi = 0,
760
- fl = file.length,
761
- pl = pattern.length
762
- ; (fi < fl) && (pi < pl)
763
- ; fi++, pi++) {
764
- this.debug('matchOne loop')
765
- var p = pattern[pi]
766
- var f = file[fi]
767
-
768
- this.debug(pattern, p, f)
769
-
770
- // should be impossible.
771
- // some invalid regexp stuff in the set.
772
- if (p === false) return false
773
-
774
- if (p === GLOBSTAR) {
775
- this.debug('GLOBSTAR', [pattern, p, f])
776
-
777
- // "**"
778
- // a/**/b/**/c would match the following:
779
- // a/b/x/y/z/c
780
- // a/x/y/z/b/c
781
- // a/b/x/b/x/c
782
- // a/b/c
783
- // To do this, take the rest of the pattern after
784
- // the **, and see if it would match the file remainder.
785
- // If so, return success.
786
- // If not, the ** "swallows" a segment, and try again.
787
- // This is recursively awful.
788
- //
789
- // a/**/b/**/c matching a/b/x/y/z/c
790
- // - a matches a
791
- // - doublestar
792
- // - matchOne(b/x/y/z/c, b/**/c)
793
- // - b matches b
794
- // - doublestar
795
- // - matchOne(x/y/z/c, c) -> no
796
- // - matchOne(y/z/c, c) -> no
797
- // - matchOne(z/c, c) -> no
798
- // - matchOne(c, c) yes, hit
799
- var fr = fi
800
- var pr = pi + 1
801
- if (pr === pl) {
802
- this.debug('** at the end')
803
- // a ** at the end will just swallow the rest.
804
- // We have found a match.
805
- // however, it will not swallow /.x, unless
806
- // options.dot is set.
807
- // . and .. are *never* matched by **, for explosively
808
- // exponential reasons.
809
- for (; fi < fl; fi++) {
810
- if (file[fi] === '.' || file[fi] === '..' ||
811
- (!options.dot && file[fi].charAt(0) === '.')) return false
812
- }
813
- return true
814
- }
815
-
816
- // ok, let's see if we can swallow whatever we can.
817
- while (fr < fl) {
818
- var swallowee = file[fr]
819
-
820
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
821
-
822
- // XXX remove this slice. Just pass the start index.
823
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
824
- this.debug('globstar found match!', fr, fl, swallowee)
825
- // found a match.
826
- return true
827
- } else {
828
- // can't swallow "." or ".." ever.
829
- // can only swallow ".foo" when explicitly asked.
830
- if (swallowee === '.' || swallowee === '..' ||
831
- (!options.dot && swallowee.charAt(0) === '.')) {
832
- this.debug('dot detected!', file, fr, pattern, pr)
833
- break
834
- }
835
-
836
- // ** swallows a segment, and continue.
837
- this.debug('globstar swallow a segment, and continue')
838
- fr++
839
- }
840
- }
841
-
842
- // no match was found.
843
- // However, in partial mode, we can't say this is necessarily over.
844
- // If there's more *pattern* left, then
845
- if (partial) {
846
- // ran out of file
847
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
848
- if (fr === fl) return true
849
- }
850
- return false
851
- }
852
-
853
- // something other than **
854
- // non-magic patterns just have to match exactly
855
- // patterns with magic have been turned into regexps.
856
- var hit
857
- if (typeof p === 'string') {
858
- if (options.nocase) {
859
- hit = f.toLowerCase() === p.toLowerCase()
860
- } else {
861
- hit = f === p
862
- }
863
- this.debug('string match', p, f, hit)
864
- } else {
865
- hit = f.match(p)
866
- this.debug('pattern match', p, f, hit)
867
- }
868
-
869
- if (!hit) return false
870
- }
871
-
872
- // Note: ending in / means that we'll get a final ""
873
- // at the end of the pattern. This can only match a
874
- // corresponding "" at the end of the file.
875
- // If the file ends in /, then it can only match a
876
- // a pattern that ends in /, unless the pattern just
877
- // doesn't have any more for it. But, a/b/ should *not*
878
- // match "a/b/*", even though "" matches against the
879
- // [^/]*? pattern, except in partial mode, where it might
880
- // simply not be reached yet.
881
- // However, a/b/ should still satisfy a/*
882
-
883
- // now either we fell off the end of the pattern, or we're done.
884
- if (fi === fl && pi === pl) {
885
- // ran out of pattern and filename at the same time.
886
- // an exact hit!
887
- return true
888
- } else if (fi === fl) {
889
- // ran out of file, but still had pattern left.
890
- // this is ok if we're doing the match as part of
891
- // a glob fs traversal.
892
- return partial
893
- } else if (pi === pl) {
894
- // ran out of pattern, still have file left.
895
- // this is only acceptable if we're on the very last
896
- // empty segment of a file with a trailing slash.
897
- // a/* should match a/b/
898
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
899
- return emptyFileEnd
900
- }
901
-
902
- // should be unreachable.
903
- throw new Error('wtf?')
904
- }
905
-
906
- // replace stuff like \* with *
907
- function globUnescape (s) {
908
- return s.replace(/\\(.)/g, '$1')
909
- }
910
-
911
- function regExpEscape (s) {
912
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
913
- }
914
-
915
- },{"brace-expansion":2,"path":undefined}],2:[function(require,module,exports){
916
- var concatMap = require('concat-map');
917
- var balanced = require('balanced-match');
918
-
919
- module.exports = expandTop;
920
-
921
- var escSlash = '\0SLASH'+Math.random()+'\0';
922
- var escOpen = '\0OPEN'+Math.random()+'\0';
923
- var escClose = '\0CLOSE'+Math.random()+'\0';
924
- var escComma = '\0COMMA'+Math.random()+'\0';
925
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
926
-
927
- function numeric(str) {
928
- return parseInt(str, 10) == str
929
- ? parseInt(str, 10)
930
- : str.charCodeAt(0);
931
- }
932
-
933
- function escapeBraces(str) {
934
- return str.split('\\\\').join(escSlash)
935
- .split('\\{').join(escOpen)
936
- .split('\\}').join(escClose)
937
- .split('\\,').join(escComma)
938
- .split('\\.').join(escPeriod);
939
- }
940
-
941
- function unescapeBraces(str) {
942
- return str.split(escSlash).join('\\')
943
- .split(escOpen).join('{')
944
- .split(escClose).join('}')
945
- .split(escComma).join(',')
946
- .split(escPeriod).join('.');
947
- }
948
-
949
-
950
- // Basically just str.split(","), but handling cases
951
- // where we have nested braced sections, which should be
952
- // treated as individual members, like {a,{b,c},d}
953
- function parseCommaParts(str) {
954
- if (!str)
955
- return [''];
956
-
957
- var parts = [];
958
- var m = balanced('{', '}', str);
959
-
960
- if (!m)
961
- return str.split(',');
962
-
963
- var pre = m.pre;
964
- var body = m.body;
965
- var post = m.post;
966
- var p = pre.split(',');
967
-
968
- p[p.length-1] += '{' + body + '}';
969
- var postParts = parseCommaParts(post);
970
- if (post.length) {
971
- p[p.length-1] += postParts.shift();
972
- p.push.apply(p, postParts);
973
- }
974
-
975
- parts.push.apply(parts, p);
976
-
977
- return parts;
978
- }
979
-
980
- function expandTop(str) {
981
- if (!str)
982
- return [];
983
-
984
- var expansions = expand(escapeBraces(str));
985
- return expansions.filter(identity).map(unescapeBraces);
986
- }
987
-
988
- function identity(e) {
989
- return e;
990
- }
991
-
992
- function embrace(str) {
993
- return '{' + str + '}';
994
- }
995
- function isPadded(el) {
996
- return /^-?0\d/.test(el);
997
- }
998
-
999
- function lte(i, y) {
1000
- return i <= y;
1001
- }
1002
- function gte(i, y) {
1003
- return i >= y;
1004
- }
1005
-
1006
- function expand(str) {
1007
- var expansions = [];
1008
-
1009
- var m = balanced('{', '}', str);
1010
- if (!m || /\$$/.test(m.pre)) return [str];
1011
-
1012
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
1013
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
1014
- var isSequence = isNumericSequence || isAlphaSequence;
1015
- var isOptions = /^(.*,)+(.+)?$/.test(m.body);
1016
- if (!isSequence && !isOptions) {
1017
- // {a},b}
1018
- if (m.post.match(/,.*}/)) {
1019
- str = m.pre + '{' + m.body + escClose + m.post;
1020
- return expand(str);
1021
- }
1022
- return [str];
1023
- }
1024
-
1025
- var n;
1026
- if (isSequence) {
1027
- n = m.body.split(/\.\./);
1028
- } else {
1029
- n = parseCommaParts(m.body);
1030
- if (n.length === 1) {
1031
- // x{{a,b}}y ==> x{a}y x{b}y
1032
- n = expand(n[0]).map(embrace);
1033
- if (n.length === 1) {
1034
- var post = m.post.length
1035
- ? expand(m.post)
1036
- : [''];
1037
- return post.map(function(p) {
1038
- return m.pre + n[0] + p;
1039
- });
1040
- }
1041
- }
1042
- }
1043
-
1044
- // at this point, n is the parts, and we know it's not a comma set
1045
- // with a single entry.
1046
-
1047
- // no need to expand pre, since it is guaranteed to be free of brace-sets
1048
- var pre = m.pre;
1049
- var post = m.post.length
1050
- ? expand(m.post)
1051
- : [''];
1052
-
1053
- var N;
1054
-
1055
- if (isSequence) {
1056
- var x = numeric(n[0]);
1057
- var y = numeric(n[1]);
1058
- var width = Math.max(n[0].length, n[1].length)
1059
- var incr = n.length == 3
1060
- ? Math.abs(numeric(n[2]))
1061
- : 1;
1062
- var test = lte;
1063
- var reverse = y < x;
1064
- if (reverse) {
1065
- incr *= -1;
1066
- test = gte;
1067
- }
1068
- var pad = n.some(isPadded);
1069
-
1070
- N = [];
1071
-
1072
- for (var i = x; test(i, y); i += incr) {
1073
- var c;
1074
- if (isAlphaSequence) {
1075
- c = String.fromCharCode(i);
1076
- if (c === '\\')
1077
- c = '';
1078
- } else {
1079
- c = String(i);
1080
- if (pad) {
1081
- var need = width - c.length;
1082
- if (need > 0) {
1083
- var z = new Array(need + 1).join('0');
1084
- if (i < 0)
1085
- c = '-' + z + c.slice(1);
1086
- else
1087
- c = z + c;
1088
- }
1089
- }
1090
- }
1091
- N.push(c);
1092
- }
1093
- } else {
1094
- N = concatMap(n, function(el) { return expand(el) });
1095
- }
1096
-
1097
- for (var j = 0; j < N.length; j++) {
1098
- for (var k = 0; k < post.length; k++) {
1099
- expansions.push([pre, N[j], post[k]].join(''))
1100
- }
1101
- }
1102
-
1103
- return expansions;
1104
- }
1105
-
1106
-
1107
- },{"balanced-match":3,"concat-map":4}],3:[function(require,module,exports){
1108
- module.exports = balanced;
1109
- function balanced(a, b, str) {
1110
- var bal = 0;
1111
- var m = {};
1112
- var ended = false;
1113
-
1114
- for (var i = 0; i < str.length; i++) {
1115
- if (a == str.substr(i, a.length)) {
1116
- if (!('start' in m)) m.start = i;
1117
- bal++;
1118
- }
1119
- else if (b == str.substr(i, b.length) && 'start' in m) {
1120
- ended = true;
1121
- bal--;
1122
- if (!bal) {
1123
- m.end = i;
1124
- m.pre = str.substr(0, m.start);
1125
- m.body = (m.end - m.start > 1)
1126
- ? str.substring(m.start + a.length, m.end)
1127
- : '';
1128
- m.post = str.slice(m.end + b.length);
1129
- return m;
1130
- }
1131
- }
1132
- }
1133
-
1134
- // if we opened more than we closed, find the one we closed
1135
- if (bal && ended) {
1136
- var start = m.start + a.length;
1137
- m = balanced(a, b, str.substr(start));
1138
- if (m) {
1139
- m.start += start;
1140
- m.end += start;
1141
- m.pre = str.slice(0, start) + m.pre;
1142
- }
1143
- return m;
1144
- }
1145
- }
1146
-
1147
- },{}],4:[function(require,module,exports){
1148
- module.exports = function (xs, fn) {
1149
- var res = [];
1150
- for (var i = 0; i < xs.length; i++) {
1151
- var x = fn(xs[i], i);
1152
- if (Array.isArray(x)) res.push.apply(res, x);
1153
- else res.push(x);
1154
- }
1155
- return res;
1156
- };
1157
-
1158
- },{}]},{},[1])(1)
1159
- });