pax_global_header00006660000000000000000000000064126002571600014511gustar00rootroot0000000000000052 comment=adbc0ab07ec8a85f76ffd1b54dd41cdb9d1d0b83 glob-base-0.3.0/000077500000000000000000000000001260025716000133445ustar00rootroot00000000000000glob-base-0.3.0/.editorconfig000066400000000000000000000006501260025716000160220ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [*.json] indent_style = space indent_size = 2 [*.yml] indent_style = space indent_size = 2 [*.md] indent_style = space indent_size = 2 trim_trailing_whitespace = false [test/fixtures/*] trim_trailing_whitespace = false insert_final_newline = falseglob-base-0.3.0/.gitattributes000066400000000000000000000001771260025716000162440ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binaryglob-base-0.3.0/.gitignore000066400000000000000000000001701260025716000153320ustar00rootroot00000000000000*.DS_Store *.sublime-* _gh_pages bower_components node_modules npm-debug.log actual test/actual temp tmp TODO.md vendor glob-base-0.3.0/.jshintrc000066400000000000000000000004311260025716000151670ustar00rootroot00000000000000{ "asi": false, "boss": true, "curly": true, "eqeqeq": true, "eqnull": true, "esnext": true, "immed": true, "latedef": false, "laxcomma": false, "mocha": true, "newcap": true, "noarg": true, "node": true, "sub": true, "undef": true, "unused": true }glob-base-0.3.0/.travis.yml000066400000000000000000000001311260025716000154500ustar00rootroot00000000000000sudo: false language: node_js node_js: - "0.10" - "0.12" - "iojs" git: depth: 10 glob-base-0.3.0/.verb.md000066400000000000000000000060341260025716000147050ustar00rootroot00000000000000# {%= name %} {%= badge("fury") %} {%= badge("travis") %} > {%= description %} Use [glob-parent](https://github.com/es128/glob-parent) if you just want the base path. {%= include("install-npm", {save: true}) %} ## Related projects {%= related(['glob-parent', 'micromatch', 'parse-glob', 'is-glob', 'braces', 'fill-range', 'expand-range']) %} ## Usage ```js var globBase = require('{%= name %}'); globBase('a/b/.git/'); //=> { base: 'a/b/.git/', isGlob: false, glob: '' }) globBase('a/b/**/e'); //=> { base: 'a/b', isGlob: true, glob: '**/e' } globBase('a/b/*.{foo,bar}'); //=> { base: 'a/b', isGlob: true, glob: '*.{foo,bar}' } globBase('a/b/.git/**'); //=> { base: 'a/b/.git', isGlob: true, glob: '**' } globBase('a/b/c/*.md'); //=> { base: 'a/b/c', isGlob: true, glob: '*.md' } globBase('a/b/c/.*.md'); //=> { base: 'a/b/c', isGlob: true, glob: '.*.md' } globBase('a/b/{c,d}'); //=> { base: 'a/b', isGlob: true, glob: '{c,d}' } globBase('!*.min.js'); //=> { base: '.', isGlob: true, glob: '!*.min.js' } globBase('!foo'); //=> { base: '.', isGlob: true, glob: '!foo' } globBase('!foo/(a|b).min.js'); //=> { base: '.', isGlob: true, glob: '!foo/(a|b).min.js' } globBase(''); //=> { base: '.', isGlob: false, glob: '' } globBase('**/*.md'); //=> { base: '.', isGlob: true, glob: '**/*.md' } globBase('**/*.min.js'); //=> { base: '.', isGlob: true, glob: '**/*.min.js' } globBase('**/.*'); //=> { base: '.', isGlob: true, glob: '**/.*' } globBase('**/d'); //=> { base: '.', isGlob: true, glob: '**/d' } globBase('*.*'); //=> { base: '.', isGlob: true, glob: '*.*' } globBase('*.min.js'); //=> { base: '.', isGlob: true, glob: '*.min.js' } globBase('*/*'); //=> { base: '.', isGlob: true, glob: '*/*' } globBase('*b'); //=> { base: '.', isGlob: true, glob: '*b' } globBase('.'); //=> { base: '.', isGlob: false, glob: '.' } globBase('.*'); //=> { base: '.', isGlob: true, glob: '.*' } globBase('./*'); //=> { base: '.', isGlob: true, glob: '*' } globBase('/a'); //=> { base: '/', isGlob: false, glob: 'a' } globBase('@(a|b)/e.f.g/'); //=> { base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' } globBase('[a-c]b*'); //=> { base: '.', isGlob: true, glob: '[a-c]b*' } globBase('a'); //=> { base: '.', isGlob: false, glob: 'a' } globBase('a.min.js'); //=> { base: '.', isGlob: false, glob: 'a.min.js' } globBase('a/'); //=> { base: 'a/', isGlob: false, glob: '' } globBase('a/**/j/**/z/*.md'); //=> { base: 'a', isGlob: true, glob: '**/j/**/z/*.md' } globBase('a/*/c/*.md'); //=> { base: 'a', isGlob: true, glob: '*/c/*.md' } globBase('a/?/c.md'); //=> { base: 'a', isGlob: true, glob: '?/c.md' } globBase('a/??/c.js'); //=> { base: 'a', isGlob: true, glob: '??/c.js' } globBase('a?b'); //=> { base: '.', isGlob: true, glob: 'a?b' } globBase('bb'); //=> { base: '.', isGlob: false, glob: 'bb' } globBase('c.md'); //=> { base: '.', isGlob: false, glob: 'c.md' } ``` ## Running tests {%= include("tests") %} ## Contributing {%= include("contributing") %} ## Author {%= include("author") %} ## License {%= copyright() %} {%= license() %} *** {%= include("footer") %} glob-base-0.3.0/LICENSE000066400000000000000000000020731260025716000143530ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015, Jon Schlinkert. 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. glob-base-0.3.0/README.md000066400000000000000000000111221260025716000146200ustar00rootroot00000000000000# glob-base [![NPM version](https://badge.fury.io/js/glob-base.svg)](http://badge.fury.io/js/glob-base) [![Build Status](https://travis-ci.org/jonschlinkert/glob-base.svg)](https://travis-ci.org/jonschlinkert/glob-base) > Returns an object with the (non-glob) base path and the actual pattern. Use [glob-parent](https://github.com/es128/glob-parent) if you just want the base path. ## Install with [npm](npmjs.org) ```bash npm i glob-base --save ``` ## Related projects * [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path * [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks. * [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. * [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification. * [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to use. * [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch. ## Usage ```js var globBase = require('glob-base'); globBase('a/b/.git/'); //=> { base: 'a/b/.git/', isGlob: false, glob: '' }) globBase('a/b/**/e'); //=> { base: 'a/b', isGlob: true, glob: '**/e' } globBase('a/b/*.{foo,bar}'); //=> { base: 'a/b', isGlob: true, glob: '*.{foo,bar}' } globBase('a/b/.git/**'); //=> { base: 'a/b/.git', isGlob: true, glob: '**' } globBase('a/b/c/*.md'); //=> { base: 'a/b/c', isGlob: true, glob: '*.md' } globBase('a/b/c/.*.md'); //=> { base: 'a/b/c', isGlob: true, glob: '.*.md' } globBase('a/b/{c,d}'); //=> { base: 'a/b', isGlob: true, glob: '{c,d}' } globBase('!*.min.js'); //=> { base: '.', isGlob: true, glob: '!*.min.js' } globBase('!foo'); //=> { base: '.', isGlob: true, glob: '!foo' } globBase('!foo/(a|b).min.js'); //=> { base: '.', isGlob: true, glob: '!foo/(a|b).min.js' } globBase(''); //=> { base: '.', isGlob: false, glob: '' } globBase('**/*.md'); //=> { base: '.', isGlob: true, glob: '**/*.md' } globBase('**/*.min.js'); //=> { base: '.', isGlob: true, glob: '**/*.min.js' } globBase('**/.*'); //=> { base: '.', isGlob: true, glob: '**/.*' } globBase('**/d'); //=> { base: '.', isGlob: true, glob: '**/d' } globBase('*.*'); //=> { base: '.', isGlob: true, glob: '*.*' } globBase('*.min.js'); //=> { base: '.', isGlob: true, glob: '*.min.js' } globBase('*/*'); //=> { base: '.', isGlob: true, glob: '*/*' } globBase('*b'); //=> { base: '.', isGlob: true, glob: '*b' } globBase('.'); //=> { base: '.', isGlob: false, glob: '.' } globBase('.*'); //=> { base: '.', isGlob: true, glob: '.*' } globBase('./*'); //=> { base: '.', isGlob: true, glob: '*' } globBase('/a'); //=> { base: '/', isGlob: false, glob: 'a' } globBase('@(a|b)/e.f.g/'); //=> { base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' } globBase('[a-c]b*'); //=> { base: '.', isGlob: true, glob: '[a-c]b*' } globBase('a'); //=> { base: '.', isGlob: false, glob: 'a' } globBase('a.min.js'); //=> { base: '.', isGlob: false, glob: 'a.min.js' } globBase('a/'); //=> { base: 'a/', isGlob: false, glob: '' } globBase('a/**/j/**/z/*.md'); //=> { base: 'a', isGlob: true, glob: '**/j/**/z/*.md' } globBase('a/*/c/*.md'); //=> { base: 'a', isGlob: true, glob: '*/c/*.md' } globBase('a/?/c.md'); //=> { base: 'a', isGlob: true, glob: '?/c.md' } globBase('a/??/c.js'); //=> { base: 'a', isGlob: true, glob: '??/c.js' } globBase('a?b'); //=> { base: '.', isGlob: true, glob: 'a?b' } globBase('bb'); //=> { base: '.', isGlob: false, glob: 'bb' } globBase('c.md'); //=> { base: '.', isGlob: false, glob: 'c.md' } ``` ## Running tests Install dev dependencies. ```bash npm i -d && npm test ``` ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/glob-base/issues) ## Author **Jon Schlinkert** + [github/jonschlinkert](https://github.com/jonschlinkert) + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright (c) 2015 Jon Schlinkert Released under the MIT license *** _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._ glob-base-0.3.0/index.js000066400000000000000000000021071260025716000150110ustar00rootroot00000000000000/*! * glob-base * * Copyright (c) 2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; var path = require('path'); var parent = require('glob-parent'); var isGlob = require('is-glob'); module.exports = function globBase(pattern) { if (typeof pattern !== 'string') { throw new TypeError('glob-base expects a string.'); } var res = {}; res.base = parent(pattern); res.isGlob = isGlob(pattern); if (res.base !== '.') { res.glob = pattern.substr(res.base.length); if (res.glob.charAt(0) === '/') { res.glob = res.glob.substr(1); } } else { res.glob = pattern; } if (!res.isGlob) { res.base = dirname(pattern); res.glob = res.base !== '.' ? pattern.substr(res.base.length) : pattern; } if (res.glob.substr(0, 2) === './') { res.glob = res.glob.substr(2); } if (res.glob.charAt(0) === '/') { res.glob = res.glob.substr(1); } return res; }; function dirname(glob) { if (glob.slice(-1) === '/') return glob; return path.dirname(glob); } glob-base-0.3.0/package.json000066400000000000000000000020321260025716000156270ustar00rootroot00000000000000{ "name": "glob-base", "description": "Returns an object with the (non-glob) base path and the actual pattern.", "version": "0.3.0", "homepage": "https://github.com/jonschlinkert/glob-base", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, "repository": { "type": "git", "url": "git://github.com/jonschlinkert/glob-base.git" }, "bugs": { "url": "https://github.com/jonschlinkert/glob-base/issues" }, "license": { "type": "MIT", "url": "https://github.com/jonschlinkert/glob-base/blob/master/LICENSE" }, "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "dependencies": { "glob-parent": "^2.0.0", "is-glob": "^2.0.0" }, "devDependencies": { "mocha": "*", "should": "^5.1.0" }, "keywords": [ "base", "directory", "dirname", "expression", "glob", "parent", "path", "pattern", "regex", "regular", "root" ] } glob-base-0.3.0/test.js000066400000000000000000000323311260025716000146630ustar00rootroot00000000000000/*! * glob-base * * Copyright (c) 2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; /* deps:mocha */ var should = require('should'); var globBase = require('./'); describe('glob-base:', function () { it('typical globs:', function () { globBase('!foo').should.eql({ base: '.', isGlob: true, glob: '!foo' }); globBase('*').should.eql({ base: '.', isGlob: true, glob: '*' }); globBase('**').should.eql({ base: '.', isGlob: true, glob: '**' }); globBase('**/*.md').should.eql({ base: '.', isGlob: true, glob: '**/*.md' }); globBase('**/*.min.js').should.eql({ base: '.', isGlob: true, glob: '**/*.min.js' }); globBase('**/*foo.js').should.eql({ base: '.', isGlob: true, glob: '**/*foo.js' }); globBase('**/.*').should.eql({ base: '.', isGlob: true, glob: '**/.*' }); globBase('**/d').should.eql({ base: '.', isGlob: true, glob: '**/d' }); globBase('*.*').should.eql({ base: '.', isGlob: true, glob: '*.*' }); globBase('*.js').should.eql({ base: '.', isGlob: true, glob: '*.js' }); globBase('*.md').should.eql({ base: '.', isGlob: true, glob: '*.md' }); globBase('*.min.js').should.eql({ base: '.', isGlob: true, glob: '*.min.js' }); globBase('*/*').should.eql({ base: '.', isGlob: true, glob: '*/*' }); globBase('*/*/*/*').should.eql({ base: '.', isGlob: true, glob: '*/*/*/*' }); globBase('*/*/*/e').should.eql({ base: '.', isGlob: true, glob: '*/*/*/e' }); globBase('*/b/*/e').should.eql({ base: '.', isGlob: true, glob: '*/b/*/e' }); globBase('*b').should.eql({ base: '.', isGlob: true, glob: '*b' }); globBase('.*').should.eql({ base: '.', isGlob: true, glob: '.*' }); globBase('./*').should.eql({ base: '.', isGlob: true, glob: '*' }); globBase('./a/**/j/**/z/*.md').should.eql({ base: './a', isGlob: true, glob: '**/j/**/z/*.md' }); globBase('./a/**/z/*.md').should.eql({ base: './a', isGlob: true, glob: '**/z/*.md' }); globBase('./node_modules/*-glob/**/*.js').should.eql({ base: './node_modules', isGlob: true, glob: '*-glob/**/*.js' }); globBase('./{a/b/{c,/foo.js}/e.f.g}').should.eql({ base: '.', isGlob: true, glob: '{a/b/{c,/foo.js}/e.f.g}' }); globBase('.a*').should.eql({ base: '.', isGlob: true, glob: '.a*' }); globBase('.b*').should.eql({ base: '.', isGlob: true, glob: '.b*' }); globBase('/*').should.eql({ base: '/', isGlob: true, glob: '*' }); globBase('a/***').should.eql({ base: 'a', isGlob: true, glob: '***' }); globBase('a/**/b/*.{foo,bar}').should.eql({ base: 'a', isGlob: true, glob: '**/b/*.{foo,bar}' }); globBase('a/**/c/*').should.eql({ base: 'a', isGlob: true, glob: '**/c/*' }); globBase('a/**/c/*.md').should.eql({ base: 'a', isGlob: true, glob: '**/c/*.md' }); globBase('a/**/e').should.eql({ base: 'a', isGlob: true, glob: '**/e' }); globBase('a/**/j/**/z/*.md').should.eql({ base: 'a', isGlob: true, glob: '**/j/**/z/*.md' }); globBase('a/**/z/*.md').should.eql({ base: 'a', isGlob: true, glob: '**/z/*.md' }); globBase('a/**c*').should.eql({ base: 'a', isGlob: true, glob: '**c*' }); globBase('a/**c/*').should.eql({ base: 'a', isGlob: true, glob: '**c/*' }); globBase('a/*/*/e').should.eql({ base: 'a', isGlob: true, glob: '*/*/e' }); globBase('a/*/c/*.md').should.eql({ base: 'a', isGlob: true, glob: '*/c/*.md' }); globBase('a/b/**/c{d,e}/**/xyz.md').should.eql({ base: 'a/b', isGlob: true, glob: '**/c{d,e}/**/xyz.md' }); globBase('a/b/**/e').should.eql({ base: 'a/b', isGlob: true, glob: '**/e' }); globBase('a/b/*.{foo,bar}').should.eql({ base: 'a/b', isGlob: true, glob: '*.{foo,bar}' }); globBase('a/b/*/e').should.eql({ base: 'a/b', isGlob: true, glob: '*/e' }); globBase('a/b/.git/').should.eql({ base: 'a/b/.git/', isGlob: false, glob: '' }); globBase('a/b/.git/**').should.eql({ base: 'a/b/.git', isGlob: true, glob: '**' }); globBase('a/b/.{foo,bar}').should.eql({ base: 'a/b', isGlob: true, glob: '.{foo,bar}' }); globBase('a/b/c/*').should.eql({ base: 'a/b/c', isGlob: true, glob: '*' }); globBase('a/b/c/**/*.min.js').should.eql({ base: 'a/b/c', isGlob: true, glob: '**/*.min.js' }); globBase('a/b/c/*.md').should.eql({ base: 'a/b/c', isGlob: true, glob: '*.md' }); globBase('a/b/c/.*.md').should.eql({ base: 'a/b/c', isGlob: true, glob: '.*.md' }); globBase('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js' }); globBase('a/b/{c,/.gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '{c,/.gitignore}' }); globBase('a/b/{c,d}/').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/' }); globBase('a/b/{c,d}/e/f.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/e/f.g' }); globBase('b/*/*/*').should.eql({ base: 'b', isGlob: true, glob: '*/*/*' }); }); it('file extensions:', function () { globBase('.md').should.eql({ base: '.', isGlob: false, glob: '.md' }); }); it('negation pattern:', function () { globBase('!*.min.js').should.eql({ base: '.', isGlob: true, glob: '!*.min.js' }); globBase('!foo').should.eql({ base: '.', isGlob: true, glob: '!foo' }); globBase('a/b/c/!foo').should.eql({ base: 'a/b/c', isGlob: true, glob: '!foo' }); globBase('!foo/(a|b).min.js').should.eql({ base: '.', isGlob: true, glob: '!foo/(a|b).min.js' }); globBase('!foo/[a-b].min.js').should.eql({ base: '.', isGlob: true, glob: '!foo/[a-b].min.js' }); globBase('!foo/{a,b}.min.js').should.eql({ base: '.', isGlob: true, glob: '!foo/{a,b}.min.js' }); }); it('extglobs:', function () { globBase('/a/b/!(a|b)/e.f.g/').should.eql({ base: '/a/b', isGlob: true, glob: '!(a|b)/e.f.g/' }); globBase('/a/b/@(a|b)/e.f.g/').should.eql({ base: '/a/b', isGlob: true, glob: '@(a|b)/e.f.g/' }); globBase('@(a|b)/e.f.g/').should.eql({ base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' }); }); it('braces: no base:', function () { globBase('/a/b/{c,/foo.js}/e.f.g/').should.eql({ base: '/a/b', isGlob: true, glob: '{c,/foo.js}/e.f.g/' }); globBase('{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}').should.eql({ base: '.', isGlob: true, glob: '{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}' }); globBase('/a/b/{c,d}/').should.eql({ base: '/a/b', isGlob: true, glob: '{c,d}/' }); globBase('/a/b/{c,d}/*.js').should.eql({ base: '/a/b', isGlob: true, glob: '{c,d}/*.js' }); globBase('/a/b/{c,d}/*.min.js').should.eql({ base: '/a/b', isGlob: true, glob: '{c,d}/*.min.js' }); globBase('/a/b/{c,d}/e.f.g/').should.eql({ base: '/a/b', isGlob: true, glob: '{c,d}/e.f.g/' }); globBase('{.,*}').should.eql({ base: '.', isGlob: true, glob: '{.,*}' }); }); it('braces in filename:', function () { globBase('a/b/.{c,.gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '.{c,.gitignore}' }); globBase('a/b/.{c,/.gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '.{c,/.gitignore}' }); globBase('a/b/.{foo,bar}').should.eql({ base: 'a/b', isGlob: true, glob: '.{foo,bar}' }); globBase('a/b/{c,.gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '{c,.gitignore}' }); globBase('a/b/{c,/.gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '{c,/.gitignore}' }); globBase('a/b/{c,/gitignore}').should.eql({ base: 'a/b', isGlob: true, glob: '{c,/gitignore}' }); globBase('a/b/{c,d}').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}' }); }); it('braces in dirname:', function () { globBase('a/b/{c,./d}/e/f.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,./d}/e/f.g' }); globBase('a/b/{c,./d}/e/f.min.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,./d}/e/f.min.g' }); globBase('a/b/{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js' }); globBase('a/b/{c,.gitignore,{a,b}}/{a,b}/*.foo.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,.gitignore,{a,b}}/{a,b}/*.foo.js' }); globBase('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js' }); globBase('a/b/{c,/d}/e/f.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,/d}/e/f.g' }); globBase('a/b/{c,/d}/e/f.min.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,/d}/e/f.min.g' }); globBase('a/b/{c,d}/').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/' }); globBase('a/b/{c,d}/*.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/*.js' }); globBase('a/b/{c,d}/*.min.js').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/*.min.js' }); globBase('a/b/{c,d}/e.f.g/').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/e.f.g/' }); globBase('a/b/{c,d}/e/f.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/e/f.g' }); globBase('a/b/{c,d}/e/f.min.g').should.eql({ base: 'a/b', isGlob: true, glob: '{c,d}/e/f.min.g' }); globBase('foo/{a,b}.min.js').should.eql({ base: 'foo', isGlob: true, glob: '{a,b}.min.js' }); }); it('regex character classes:', function () { globBase('[a-c]b*').should.eql({ base: '.', isGlob: true, glob: '[a-c]b*' }); globBase('[a-j]*[^c]').should.eql({ base: '.', isGlob: true, glob: '[a-j]*[^c]' }); globBase('[a-j]*[^c]b/c').should.eql({ base: '.', isGlob: true, glob: '[a-j]*[^c]b/c' }); globBase('[a-j]*[^c]bc').should.eql({ base: '.', isGlob: true, glob: '[a-j]*[^c]bc' }); globBase('[ab][ab]').should.eql({ base: '.', isGlob: true, glob: '[ab][ab]' }); globBase('foo/[a-b].min.js').should.eql({ base: 'foo', isGlob: true, glob: '[a-b].min.js' }); }); it('qmarks:', function () { globBase('?').should.eql({ base: '.', isGlob: true, glob: '?' }); globBase('?/?').should.eql({ base: '.', isGlob: true, glob: '?/?' }); globBase('??').should.eql({ base: '.', isGlob: true, glob: '??' }); globBase('???').should.eql({ base: '.', isGlob: true, glob: '???' }); globBase('?a').should.eql({ base: '.', isGlob: true, glob: '?a' }); globBase('?b').should.eql({ base: '.', isGlob: true, glob: '?b' }); globBase('a?b').should.eql({ base: '.', isGlob: true, glob: 'a?b' }); globBase('a/?/c.js').should.eql({ base: 'a', isGlob: true, glob: '?/c.js' }); globBase('a/?/c.md').should.eql({ base: 'a', isGlob: true, glob: '?/c.md' }); globBase('a/?/c/?/*/f.js').should.eql({ base: 'a', isGlob: true, glob: '?/c/?/*/f.js' }); globBase('a/?/c/?/*/f.md').should.eql({ base: 'a', isGlob: true, glob: '?/c/?/*/f.md' }); globBase('a/?/c/?/e.js').should.eql({ base: 'a', isGlob: true, glob: '?/c/?/e.js' }); globBase('a/?/c/?/e.md').should.eql({ base: 'a', isGlob: true, glob: '?/c/?/e.md' }); globBase('a/?/c/???/e.js').should.eql({ base: 'a', isGlob: true, glob: '?/c/???/e.js' }); globBase('a/?/c/???/e.md').should.eql({ base: 'a', isGlob: true, glob: '?/c/???/e.md' }); globBase('a/??/c.js').should.eql({ base: 'a', isGlob: true, glob: '??/c.js' }); globBase('a/??/c.md').should.eql({ base: 'a', isGlob: true, glob: '??/c.md' }); globBase('a/???/c.js').should.eql({ base: 'a', isGlob: true, glob: '???/c.js' }); globBase('a/???/c.md').should.eql({ base: 'a', isGlob: true, glob: '???/c.md' }); globBase('a/????/c.js').should.eql({ base: 'a', isGlob: true, glob: '????/c.js' }); }); it('non-glob pattern:', function () { globBase('').should.eql({ base: '.', isGlob: false, glob: '' }); globBase('.').should.eql({ base: '.', isGlob: false, glob: '.' }); globBase('a').should.eql({ base: '.', isGlob: false, glob: 'a' }); globBase('.a').should.eql({ base: '.', isGlob: false, glob: '.a' }); globBase('/a').should.eql({ base: '/', isGlob: false, glob: 'a' }); globBase('a/').should.eql({ base: 'a/', isGlob: false, glob: '' }); globBase('/a/').should.eql({ base: '/a/', isGlob: false, glob: '' }); globBase('/a/b/c').should.eql({ base: '/a/b', isGlob: false, glob: 'c' }); globBase('/a/b/c/').should.eql({ base: '/a/b/c/', isGlob: false, glob: '' }); globBase('a/b/c/').should.eql({ base: 'a/b/c/', isGlob: false, glob: '' }); globBase('a.min.js').should.eql({ base: '.', isGlob: false, glob: 'a.min.js' }); globBase('a/.x.md').should.eql({ base: 'a', isGlob: false, glob: '.x.md' }); globBase('a/b/.gitignore').should.eql({ base: 'a/b', isGlob: false, glob: '.gitignore' }); globBase('a/b/c/d.md').should.eql({ base: 'a/b/c', isGlob: false, glob: 'd.md' }); globBase('a/b/c/d.e.f/g.min.js').should.eql({ base: 'a/b/c/d.e.f', isGlob: false, glob: 'g.min.js' }); globBase('a/b/.git').should.eql({ base: 'a/b', isGlob: false, glob: '.git' }); globBase('a/b/.git/').should.eql({ base: 'a/b/.git/', isGlob: false, glob: '' }); globBase('a/b/c').should.eql({ base: 'a/b', isGlob: false, glob: 'c' }); globBase('a/b/c.d/e.md').should.eql({ base: 'a/b/c.d', isGlob: false, glob: 'e.md' }); globBase('a/b/c.md').should.eql({ base: 'a/b', isGlob: false, glob: 'c.md' }); globBase('a/b/c.min.js').should.eql({ base: 'a/b', isGlob: false, glob: 'c.min.js' }); globBase('a/b/git/').should.eql({ base: 'a/b/git/', isGlob: false, glob: '' }); globBase('aa').should.eql({ base: '.', isGlob: false, glob: 'aa' }); globBase('ab').should.eql({ base: '.', isGlob: false, glob: 'ab' }); globBase('bb').should.eql({ base: '.', isGlob: false, glob: 'bb' }); globBase('c.md').should.eql({ base: '.', isGlob: false, glob: 'c.md' }); globBase('foo').should.eql({ base: '.', isGlob: false, glob: 'foo' }); }); });