pax_global_header00006660000000000000000000000064130012475540014513gustar00rootroot0000000000000052 comment=d27045f0ea33c7ef6068802a659f7bdacf6892ca to-absolute-glob-2.0.1/000077500000000000000000000000001300124755400146725ustar00rootroot00000000000000to-absolute-glob-2.0.1/.editorconfig000066400000000000000000000004051300124755400173460ustar00rootroot00000000000000root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [{**/{actual,fixtures,expected,templates}/**,*.md}] trim_trailing_whitespace = false insert_final_newline = falseto-absolute-glob-2.0.1/.eslintrc.json000066400000000000000000000071251300124755400174730ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], "brace-style": [2, "1tbs", { "allowSingleLine": true }], "comma-dangle": [2, "never"], "comma-spacing": [2, { "before": false, "after": true }], "comma-style": [2, "last"], "constructor-super": 2, "curly": [2, "multi-line"], "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], "handle-callback-err": [2, "^(err|error)$" ], "indent": [2, 2, { "SwitchCase": 1 }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [2, "functions"], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [2, { "max": 1 }], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "no-useless-call": 0, "no-with": 2, "one-var": [0, { "initialized": "never" }], "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], "padded-blocks": [0, "never"], "quotes": [2, "single", "avoid-escape"], "radix": 2, "semi": [2, "always"], "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], "yoda": [2, "never"] } } to-absolute-glob-2.0.1/.gitattributes000066400000000000000000000002001300124755400175550ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binary to-absolute-glob-2.0.1/.gitignore000066400000000000000000000003431300124755400166620ustar00rootroot00000000000000# always ignore files *.DS_Store *.sublime-* # test related, or directories generated by tests test/actual actual coverage # npm node_modules npm-debug.log # misc _gh_pages benchmark bower_components vendor temp tmp TODO.md to-absolute-glob-2.0.1/.travis.yml000066400000000000000000000001131300124755400167760ustar00rootroot00000000000000sudo: false language: node_js node_js: - node - '6' - '5' - '0.12' to-absolute-glob-2.0.1/.verb.md000066400000000000000000000023261300124755400162330ustar00rootroot00000000000000## Usage ```js var toAbsGlob = require('{%= name %}'); toAbsGlob('a/*.js'); //=> '/dev/foo/a/*.js' ``` ## Examples Given the current project folder (cwd) is `/dev/foo/`: **makes a path absolute** ```js toAbsGlob('a'); //=> '/dev/foo/a' ``` **makes a glob absolute** ```js toAbsGlob('a/*.js'); //=> '/dev/foo/a/*.js' ``` **retains trailing slashes** ```js toAbsGlob('a/*/'); //=> '/dev/foo/a/*/' ``` **retains trailing slashes with cwd** ```js toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname}); //=> '/dev/foo/' ``` **makes a negative glob absolute** ```js toAbsGlob('!a/*.js'); //=> '!/dev/foo/a/*.js' ``` **from a cwd** ```js toAbsGlob('a/*.js', {cwd: 'foo'}); //=> '/dev/foo/foo/a/*.js' ``` **makes a negative glob absolute from a cwd** ```js toAbsGlob('!a/*.js', {cwd: 'foo'}); //=> '!/dev/foo/foo/a/*.js' ``` **from a root path** ```js toAbsGlob('/a/*.js', {root: 'baz'}); //=> '/dev/foo/baz/a/*.js' ``` **from a root slash** ```js toAbsGlob('/a/*.js', {root: '/'}); //=> '/dev/foo/a/*.js' ``` **from a negative root path** ```js toAbsGlob('!/a/*.js', {root: 'baz'}); //=> '!/dev/foo/baz/a/*.js' ``` **from a negative root slash** ```js toAbsGlob('!/a/*.js', {root: '/'}); //=> '!/dev/foo/a/*.js' ``` to-absolute-glob-2.0.1/LICENSE000066400000000000000000000020771300124755400157050ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015-2016, 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. to-absolute-glob-2.0.1/appveyor.yml000066400000000000000000000011211300124755400172550ustar00rootroot00000000000000# Test against this version of Node.js environment: matrix: # node.js - nodejs_version: "6.0" - nodejs_version: "5.0" - nodejs_version: "4.0" - nodejs_version: "0.12" - nodejs_version: "0.10" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules - npm install # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version # run tests - npm test # Don't actually build. build: off to-absolute-glob-2.0.1/examples.js000066400000000000000000000011551300124755400170500ustar00rootroot00000000000000 var toAbsGlob = require('./'); console.log(toAbsGlob('a')) console.log(toAbsGlob('a/*.js')) console.log(toAbsGlob('a/*/')) console.log(toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname})) console.log(toAbsGlob('!a/*.js')) console.log(toAbsGlob('a/*.js', {cwd: 'foo'})) console.log(toAbsGlob('!a/*.js', {cwd: 'foo'})) console.log(toAbsGlob('/a/*.js', {root: 'baz'})) console.log(toAbsGlob('/a/*.js', {root: '/'})) console.log(toAbsGlob('!/a/*.js', {root: 'baz'})) console.log(toAbsGlob('!/a/*.js', {root: '/'})) console.log(toAbsGlob('/\\!/a/*.js', {root: '/'})) console.log(toAbsGlob('/\\!\\a/*.js', {root: '/'})) to-absolute-glob-2.0.1/index.js000066400000000000000000000034021300124755400163360ustar00rootroot00000000000000'use strict'; var path = require('path'); var extend = require('extend-shallow'); var isNegated = require('is-negated-glob'); var isAbsolute = require('is-absolute'); module.exports = function(glob, options) { // shallow clone options var opts = extend({}, options); // ensure cwd is absolute var cwd = path.resolve(opts.cwd ? opts.cwd : process.cwd()); cwd = unixify(cwd); var rootDir = opts.root; // if `options.root` is defined, ensure it's absolute if (rootDir) { rootDir = unixify(rootDir); if (process.platform === 'win32' || !isAbsolute(rootDir)) { rootDir = unixify(path.resolve(rootDir)); } } // trim starting ./ from glob patterns if (glob.slice(0, 2) === './') { glob = glob.slice(2); } // when the glob pattern is only a . use an empty string if (glob.length === 1 && glob === '.') { glob = ''; } // store last character before glob is modified var suffix = glob.slice(-1); // check to see if glob is negated (and not a leading negated-extglob) var ing = isNegated(glob); glob = ing.pattern; // make glob absolute if (rootDir && glob.charAt(0) === '/') { glob = join(rootDir, glob); } else if (!isAbsolute(glob) || glob.slice(0, 1) === '\\') { glob = join(cwd, glob); } // if glob had a trailing `/`, re-add it now in case it was removed if (suffix === '/' && glob.slice(-1) !== '/') { glob += '/'; } // re-add leading `!` if it was removed return ing.negated ? '!' + glob : glob; }; function unixify(filepath) { return filepath.replace(/\\/g, '/'); } function join(dir, glob) { if (dir.charAt(dir.length - 1) === '/') { dir = dir.slice(0, -1); } if (glob.charAt(0) === '/') { glob = glob.slice(1); } if (!glob) return dir; return dir + '/' + glob; } to-absolute-glob-2.0.1/package.json000066400000000000000000000032111300124755400171550ustar00rootroot00000000000000{ "name": "to-absolute-glob", "description": "Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.", "version": "2.0.1", "homepage": "https://github.com/jonschlinkert/to-absolute-glob", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ "Blaine Bublitz (https://twitter.com/BlaineBublitz)", "Brian Woodward (https://github.com/doowb)", "Erik Kemperman (https://github.com/erikkemperman)", "Jon Schlinkert (http://twitter.com/jonschlinkert)" ], "repository": "jonschlinkert/to-absolute-glob", "bugs": { "url": "https://github.com/jonschlinkert/to-absolute-glob/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "dependencies": { "extend-shallow": "^2.0.1", "is-absolute": "^0.2.5", "is-negated-glob": "^1.0.0" }, "devDependencies": { "gulp-format-md": "^0.1.11", "mocha": "^3.0.2" }, "keywords": [ "absolute", "file", "filepath", "glob", "negate", "negative", "path", "pattern", "resolve", "to" ], "verb": { "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "lint": { "reflinks": true }, "related": { "list": [ "has-glob", "is-glob", "is-valid-glob" ] }, "reflinks": [ "verb", "verb-generate-readme" ] } } to-absolute-glob-2.0.1/readme.md000066400000000000000000000105521300124755400164540ustar00rootroot00000000000000# to-absolute-glob [![NPM version](https://img.shields.io/npm/v/to-absolute-glob.svg?style=flat)](https://www.npmjs.com/package/to-absolute-glob) [![NPM downloads](https://img.shields.io/npm/dm/to-absolute-glob.svg?style=flat)](https://npmjs.org/package/to-absolute-glob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/to-absolute-glob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/to-absolute-glob) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/to-absolute-glob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/to-absolute-glob) > Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save to-absolute-glob ``` ## Usage ```js var toAbsGlob = require('to-absolute-glob'); toAbsGlob('a/*.js'); //=> '/dev/foo/a/*.js' ``` ## Examples Given the current project folder (cwd) is `/dev/foo/`: **makes a path absolute** ```js toAbsGlob('a'); //=> '/dev/foo/a' ``` **makes a glob absolute** ```js toAbsGlob('a/*.js'); //=> '/dev/foo/a/*.js' ``` **retains trailing slashes** ```js toAbsGlob('a/*/'); //=> '/dev/foo/a/*/' ``` **retains trailing slashes with cwd** ```js toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname}); //=> '/dev/foo/' ``` **makes a negative glob absolute** ```js toAbsGlob('!a/*.js'); //=> '!/dev/foo/a/*.js' ``` **from a cwd** ```js toAbsGlob('a/*.js', {cwd: 'foo'}); //=> '/dev/foo/foo/a/*.js' ``` **makes a negative glob absolute from a cwd** ```js toAbsGlob('!a/*.js', {cwd: 'foo'}); //=> '!/dev/foo/foo/a/*.js' ``` **from a root path** ```js toAbsGlob('/a/*.js', {root: 'baz'}); //=> '/dev/foo/baz/a/*.js' ``` **from a root slash** ```js toAbsGlob('/a/*.js', {root: '/'}); //=> '/dev/foo/a/*.js' ``` **from a negative root path** ```js toAbsGlob('!/a/*.js', {root: 'baz'}); //=> '!/dev/foo/baz/a/*.js' ``` **from a negative root slash** ```js toAbsGlob('!/a/*.js', {root: '/'}); //=> '!/dev/foo/a/*.js' ``` ## About ### Related projects * [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.") * [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") * [is-valid-glob](https://www.npmjs.com/package/is-valid-glob): Return true if a value is a valid glob pattern or patterns. | [homepage](https://github.com/jonschlinkert/is-valid-glob "Return true if a value is a valid glob pattern or patterns.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Contributors | **Commits** | **Contributor**
| | --- | --- | | 16 | [doowb](https://github.com/doowb) | | 13 | [jonschlinkert](https://github.com/jonschlinkert) | | 1 | [erikkemperman](https://github.com/erikkemperman) | ### Building docs _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ To generate the readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm install -g verb verb-generate-readme && verb ``` ### Running tests Install dev dependencies: ```sh $ npm install -d && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ### License Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT license](https://github.com/jonschlinkert/to-absolute-glob/blob/master/LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 17, 2016._to-absolute-glob-2.0.1/test.js000066400000000000000000000071041300124755400162110ustar00rootroot00000000000000'use strict'; require('mocha'); var path = require('path'); var assert = require('assert'); var resolve = require('./'); var sep = path.sep; var fixture; var actual; function unixify(filepath) { return filepath.replace(/\\/g, '/'); } describe('resolve', function () { describe('posix', function () { it('should make a path absolute', function () { assert.equal(resolve('a'), unixify(path.resolve('a'))); }); it('should make a glob absolute', function () { assert.equal(resolve('a/*.js'), unixify(path.resolve('a/*.js'))); }); it('should retain trailing slashes', function () { actual = resolve('a/*/'); assert.equal(actual, unixify(path.resolve('a/*')) + '/'); assert.equal(actual.slice(-1), '/'); }); it('should retain trailing slashes with cwd', function () { fixture = 'fixtures/whatsgoingon/*/'; actual = resolve(fixture, {cwd: __dirname}); assert.equal(actual, unixify(path.resolve(fixture)) + '/'); assert.equal(actual.slice(-1), '/'); }); it('should handle ./ at the beginnnig of a glob', function () { fixture = './fixtures/whatsgoingon/*/'; actual = resolve(fixture, {cwd: __dirname}); assert.equal(actual, unixify(path.resolve(fixture)) + '/'); }); it('should make a negative glob absolute', function () { actual = resolve('!a/*.js'); assert.equal(actual, '!' + unixify(path.resolve('a/*.js'))); }); it('should make a negative extglob absolute', function () { actual = resolve('!(foo)'); assert.equal(actual, unixify(path.resolve('!(foo)'))); }); it('should make an escaped negative extglob absolute', function () { actual = resolve('\\!(foo)'); assert.equal(actual, unixify(path.resolve('.')) + '/\\!(foo)'); }); it('should make a glob absolute from a cwd', function () { actual = resolve('a/*.js', {cwd: 'foo'}); assert.equal(actual, unixify(path.resolve('foo/a/*.js'))); }); it('should make a negative glob absolute from a cwd', function () { actual = resolve('!a/*.js', {cwd: 'foo'}); assert.equal(actual, '!' + unixify(path.resolve('foo/a/*.js'))); }); it('should make a glob absolute from a root path', function () { actual = resolve('/a/*.js', {root: 'foo'}); assert.equal(actual, unixify(path.resolve('foo/a/*.js'))); }); it('should make a glob absolute from a root slash', function () { actual = resolve('/a/*.js', {root: '/'}); assert.equal(actual, unixify(path.resolve('/a/*.js'))); }); it('should make a glob absolute from a negative root path', function () { actual = resolve('!/a/*.js', {root: 'foo'}); assert.equal(actual, '!' + unixify(path.resolve('foo/a/*.js'))); }); it('should make a negative glob absolute from a negative root path', function () { actual = resolve('!/a/*.js', {root: '/'}) assert.equal(actual, '!' + unixify(path.resolve('/a/*.js'))); }); }); describe('windows', function () { it('should make an escaped negative extglob absolute', function () { actual = resolve('foo/bar\\!(baz)'); assert.equal(actual, unixify(path.resolve('foo/bar')) + '\\!(baz)'); }); it('should make a glob absolute from a root path', function () { actual = resolve('/a/*.js', {root: 'foo\\bar\\baz'}); assert.equal(actual, unixify(path.resolve('foo/bar/baz/a/*.js'))); }); it('should make a glob absolute from a root slash', function () { actual = resolve('/a/*.js', {root: '\\'}); assert.equal(actual, unixify(path.resolve('/a/*.js'))); }); }); });