Add node modules and compiled JavaScript from main
This commit is contained in:
parent
8bccaeaf7c
commit
4181bfdf50
7465 changed files with 1775003 additions and 2 deletions
149
node_modules/sane/README.md
generated
vendored
Normal file
149
node_modules/sane/README.md
generated
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
[](https://circleci.com/gh/amasad/sane)
|
||||
|
||||
sane
|
||||
----
|
||||
|
||||
I've been driven to insanity by node filesystem watcher wrappers.
|
||||
Sane aims to be fast, small, and reliable file system watcher. It does that by:
|
||||
|
||||
* By default stays away from fs polling because it's very slow and cpu intensive
|
||||
* Uses `fs.watch` by default and sensibly works around the various issues
|
||||
* Maintains a consistent API across different platforms
|
||||
* Where `fs.watch` is not reliable you have the choice of using the following alternatives:
|
||||
* [the facebook watchman library](https://facebook.github.io/watchman/)
|
||||
* [the watchexec library](https://github.com/watchexec/watchexec)
|
||||
* polling
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install sane
|
||||
```
|
||||
|
||||
## How to choose a mode
|
||||
|
||||
Don't worry too much about choosing the correct mode upfront because sane
|
||||
maintains the same API across all modes and will be easy to switch.
|
||||
|
||||
* If you're only supporting Linux and OS X, `watchman` would be the most reliable mode
|
||||
* If you're using node > v0.10.0 use the default mode
|
||||
* If you're running OS X and you're watching a lot of directories and you're running into https://github.com/joyent/node/issues/5463, use `watchman`
|
||||
* If you're in an environment where native file system events aren't available (like Vagrant), you should use polling
|
||||
* Otherwise, the default mode should work well for you
|
||||
|
||||
## API
|
||||
|
||||
### sane(dir, options)
|
||||
|
||||
Watches a directory and all its descendant directories for changes, deletions, and additions on files and directories.
|
||||
|
||||
```js
|
||||
var watcher = sane('path/to/dir', {glob: ['**/*.js', '**/*.css']});
|
||||
watcher.on('ready', function () { console.log('ready') });
|
||||
watcher.on('change', function (filepath, root, stat) { console.log('file changed', filepath); });
|
||||
watcher.on('add', function (filepath, root, stat) { console.log('file added', filepath); });
|
||||
watcher.on('delete', function (filepath, root) { console.log('file deleted', filepath); });
|
||||
// close
|
||||
watcher.close();
|
||||
```
|
||||
|
||||
options:
|
||||
|
||||
* `glob`: a single string glob pattern or an array of them.
|
||||
* `poll`: puts the watcher in polling mode. Under the hood that means `fs.watchFile`.
|
||||
* `watchman`: makes the watcher use [watchman](https://facebook.github.io/watchman/).
|
||||
* `watchmanPath`: sets a custom path for `watchman` binary.
|
||||
* `watchexec`: makes the watcher use [watchexec](https://github.com/watchexec/watchexec).
|
||||
* `dot`: enables watching files/directories that start with a dot.
|
||||
* `ignored`: a glob, regex, function, or array of any combination.
|
||||
|
||||
For the glob pattern documentation, see [micromatch](https://github.com/micromatch/micromatch).
|
||||
If you choose to use `watchman` you'll have to [install watchman yourself](https://facebook.github.io/watchman/docs/install.html)).
|
||||
If you choose to use `watchexec` you'll have to [install watchexec yourself](https://github.com/watchexec/watchexec)).
|
||||
For the ignored options, see [anymatch](https://github.com/es128/anymatch).
|
||||
|
||||
### sane.NodeWatcher(dir, options)
|
||||
|
||||
The default watcher class. Uses `fs.watch` under the hood, and takes the same options as `sane(dir, options)`.
|
||||
|
||||
### sane.WatchmanWatcher(dir, options)
|
||||
|
||||
The watchman watcher class. Takes the same options as `sane(dir, options)`.
|
||||
|
||||
### sane.Watchexec(dir, options)
|
||||
|
||||
The watchexec watcher class. Takes the same options as `sane(dir, options)`.
|
||||
|
||||
### sane.PollWatcher(dir, options)
|
||||
|
||||
The polling watcher class. Takes the same options as `sane(dir, options)` with the addition of:
|
||||
|
||||
* interval: indicates how often the files should be polled. (passed to fs.watchFile)
|
||||
|
||||
### sane.{Node|Watchman|Watchexec|Poll}Watcher#close
|
||||
|
||||
Stops watching.
|
||||
|
||||
### sane.{Node|Watchman|Watchexec|Poll}Watcher events
|
||||
|
||||
Emits the following events:
|
||||
|
||||
All events are passed the file/dir path relative to the root directory
|
||||
* `ready` when the program is ready to detect events in the directory
|
||||
* `change` when a file changes
|
||||
* `add` when a file or directory has been added
|
||||
* `delete` when a file or directory has been deleted
|
||||
|
||||
## CLI
|
||||
|
||||
This module includes a simple command line interface, which you can install with `npm install sane -g`.
|
||||
|
||||
```
|
||||
Usage: sane <command> [...directory] [--glob=<filePattern>] [--poll] [--watchman] [--watchman-path=<watchmanBinaryPath>] [--dot] [--wait=<seconds>]
|
||||
|
||||
OPTIONS:
|
||||
--glob=<filePattern>
|
||||
A single string glob pattern or an array of them.
|
||||
|
||||
--ignored=<filePattern>
|
||||
A glob, regex, function, or array of any combination.
|
||||
|
||||
--poll, -p
|
||||
Use polling mode.
|
||||
|
||||
--watchman, -w
|
||||
Use watchman (if available).
|
||||
|
||||
--watchman-path=<watchmanBinaryPath>
|
||||
Sets a custom path for watchman binary (if using this mode).
|
||||
|
||||
--dot, -d
|
||||
Enables watching files/directories that start with a dot.
|
||||
|
||||
--wait=<seconds>
|
||||
Duration, in seconds, that watching will be disabled
|
||||
after running <command>. Setting this option will
|
||||
throttle calls to <command> for the specified duration.
|
||||
--quiet, -q
|
||||
Disables sane's console output
|
||||
|
||||
--changes-only, -o
|
||||
Runs <command> only when a change occur. Skips running <command> at startup
|
||||
```
|
||||
|
||||
It will watch the given `directory` and run the given <command> every time a file changes.
|
||||
|
||||
### CLI example usage
|
||||
- `sane 'echo "A command ran"'`
|
||||
- `sane 'echo "A command ran"' --glob='**/*.css'`
|
||||
- `sane 'echo "A command ran"' site/assets/css --glob='**/*.css'`
|
||||
- `sane 'echo "A command ran"' --glob='**/*.css' --ignored='**/ignore.css'`
|
||||
- `sane 'echo "A command ran"' --wait=3`
|
||||
- `sane 'echo "A command ran"' -p`
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
## Credits
|
||||
The CLI was originally based on the [watch CLI](https://github.com/mikeal/watch). Watch is licensed under the Apache License Version 2.0.
|
40
node_modules/sane/index.js
generated
vendored
Executable file
40
node_modules/sane/index.js
generated
vendored
Executable file
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
const NodeWatcher = require('./src/node_watcher');
|
||||
const PollWatcher = require('./src/poll_watcher');
|
||||
const WatchmanWatcher = require('./src/watchman_watcher');
|
||||
const WatchexecWatcher = require('./src/watchexec_watcher');
|
||||
|
||||
function throwNoFSEventsSupports() {
|
||||
throw new Error('Sane >= 4 no longer support the fsevents module.');
|
||||
}
|
||||
|
||||
function sane(dir, options) {
|
||||
options = options || {};
|
||||
if (options.watcher) {
|
||||
const WatcherClass = require(options.watcher);
|
||||
return new WatcherClass(dir, options);
|
||||
} else if (options.poll) {
|
||||
return new PollWatcher(dir, options);
|
||||
} else if (options.watchman) {
|
||||
return new WatchmanWatcher(dir, options);
|
||||
} else if (options.watchexec) {
|
||||
return new WatchexecWatcher(dir, options);
|
||||
} else if (options.fsevents) {
|
||||
throwNoFSEventsSupports();
|
||||
} else {
|
||||
return new NodeWatcher(dir, options);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = sane;
|
||||
sane.NodeWatcher = NodeWatcher;
|
||||
sane.PollWatcher = PollWatcher;
|
||||
sane.WatchmanWatcher = WatchmanWatcher;
|
||||
sane.WatchexecWatcher = WatchexecWatcher;
|
||||
|
||||
Object.defineProperty(sane, 'FSEventsWatcher', {
|
||||
get() {
|
||||
return throwNoFSEventsSupports();
|
||||
},
|
||||
});
|
15
node_modules/sane/node_modules/anymatch/LICENSE
generated
vendored
Normal file
15
node_modules/sane/node_modules/anymatch/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) 2014 Elan Shanker
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
99
node_modules/sane/node_modules/anymatch/README.md
generated
vendored
Normal file
99
node_modules/sane/node_modules/anymatch/README.md
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
anymatch [](https://travis-ci.org/micromatch/anymatch) [](https://coveralls.io/r/micromatch/anymatch?branch=master)
|
||||
======
|
||||
Javascript module to match a string against a regular expression, glob, string,
|
||||
or function that takes the string as an argument and returns a truthy or falsy
|
||||
value. The matcher can also be an array of any or all of these. Useful for
|
||||
allowing a very flexible user-defined config to define things like file paths.
|
||||
|
||||
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__
|
||||
|
||||
[](https://nodei.co/npm/anymatch/)
|
||||
[](https://nodei.co/npm-dl/anymatch/)
|
||||
|
||||
Usage
|
||||
-----
|
||||
```sh
|
||||
npm install anymatch --save
|
||||
```
|
||||
|
||||
#### anymatch (matchers, testString, [returnIndex], [startIndex], [endIndex])
|
||||
* __matchers__: (_Array|String|RegExp|Function_)
|
||||
String to be directly matched, string with glob patterns, regular expression
|
||||
test, function that takes the testString as an argument and returns a truthy
|
||||
value if it should be matched, or an array of any number and mix of these types.
|
||||
* __testString__: (_String|Array_) The string to test against the matchers. If
|
||||
passed as an array, the first element of the array will be used as the
|
||||
`testString` for non-function matchers, while the entire array will be applied
|
||||
as the arguments for function matchers.
|
||||
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of
|
||||
the first matcher that that testString matched, or -1 if no match, instead of a
|
||||
boolean result.
|
||||
* __startIndex, endIndex__: (_Integer [optional]_) Can be used to define a
|
||||
subset out of the array of provided matchers to test against. Can be useful
|
||||
with bound matcher functions (see below). When used with `returnIndex = true`
|
||||
preserves original indexing. Behaves the same as `Array.prototype.slice` (i.e.
|
||||
includes array members up to, but not including endIndex).
|
||||
|
||||
```js
|
||||
var anymatch = require('anymatch');
|
||||
|
||||
var matchers = [
|
||||
'path/to/file.js',
|
||||
'path/anyjs/**/*.js',
|
||||
/foo\.js$/,
|
||||
function (string) {
|
||||
return string.indexOf('bar') !== -1 && string.length > 10
|
||||
}
|
||||
];
|
||||
|
||||
anymatch(matchers, 'path/to/file.js'); // true
|
||||
anymatch(matchers, 'path/anyjs/baz.js'); // true
|
||||
anymatch(matchers, 'path/to/foo.js'); // true
|
||||
anymatch(matchers, 'path/to/bar.js'); // true
|
||||
anymatch(matchers, 'bar.js'); // false
|
||||
|
||||
// returnIndex = true
|
||||
anymatch(matchers, 'foo.js', true); // 2
|
||||
anymatch(matchers, 'path/anyjs/foo.js', true); // 1
|
||||
|
||||
// skip matchers
|
||||
anymatch(matchers, 'path/to/file.js', false, 1); // false
|
||||
anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); // 2
|
||||
anymatch(matchers, 'path/to/bar.js', true, 0, 3); // -1
|
||||
|
||||
// using globs to match directories and their children
|
||||
anymatch('node_modules', 'node_modules'); // true
|
||||
anymatch('node_modules', 'node_modules/somelib/index.js'); // false
|
||||
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
|
||||
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
|
||||
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
|
||||
```
|
||||
|
||||
#### anymatch (matchers)
|
||||
You can also pass in only your matcher(s) to get a curried function that has
|
||||
already been bound to the provided matching criteria. This can be used as an
|
||||
`Array.prototype.filter` callback.
|
||||
|
||||
```js
|
||||
var matcher = anymatch(matchers);
|
||||
|
||||
matcher('path/to/file.js'); // true
|
||||
matcher('path/anyjs/baz.js', true); // 1
|
||||
matcher('path/anyjs/baz.js', true, 2); // -1
|
||||
|
||||
['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
|
||||
```
|
||||
|
||||
Change Log
|
||||
----------
|
||||
[See release notes page on GitHub](https://github.com/micromatch/anymatch/releases)
|
||||
|
||||
NOTE: As of v2.0.0, [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information).
|
||||
|
||||
NOTE: As of v1.2.0, anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
|
||||
for glob pattern matching. Issues with glob pattern matching should be
|
||||
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues).
|
||||
|
||||
License
|
||||
-------
|
||||
[ISC](https://raw.github.com/micromatch/anymatch/master/LICENSE)
|
67
node_modules/sane/node_modules/anymatch/index.js
generated
vendored
Normal file
67
node_modules/sane/node_modules/anymatch/index.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
'use strict';
|
||||
|
||||
var micromatch = require('micromatch');
|
||||
var normalize = require('normalize-path');
|
||||
var path = require('path'); // required for tests.
|
||||
var arrify = function(a) { return a == null ? [] : (Array.isArray(a) ? a : [a]); };
|
||||
|
||||
var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
|
||||
criteria = arrify(criteria);
|
||||
value = arrify(value);
|
||||
if (arguments.length === 1) {
|
||||
return anymatch.bind(null, criteria.map(function(criterion) {
|
||||
return typeof criterion === 'string' && criterion[0] !== '!' ?
|
||||
micromatch.matcher(criterion) : criterion;
|
||||
}));
|
||||
}
|
||||
startIndex = startIndex || 0;
|
||||
var string = value[0];
|
||||
var altString, altValue;
|
||||
var matched = false;
|
||||
var matchIndex = -1;
|
||||
function testCriteria(criterion, index) {
|
||||
var result;
|
||||
switch (Object.prototype.toString.call(criterion)) {
|
||||
case '[object String]':
|
||||
result = string === criterion || altString && altString === criterion;
|
||||
result = result || micromatch.isMatch(string, criterion);
|
||||
break;
|
||||
case '[object RegExp]':
|
||||
result = criterion.test(string) || altString && criterion.test(altString);
|
||||
break;
|
||||
case '[object Function]':
|
||||
result = criterion.apply(null, value);
|
||||
result = result || altValue && criterion.apply(null, altValue);
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
}
|
||||
if (result) {
|
||||
matchIndex = index + startIndex;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var crit = criteria;
|
||||
var negGlobs = crit.reduce(function(arr, criterion, index) {
|
||||
if (typeof criterion === 'string' && criterion[0] === '!') {
|
||||
if (crit === criteria) {
|
||||
// make a copy before modifying
|
||||
crit = crit.slice();
|
||||
}
|
||||
crit[index] = null;
|
||||
arr.push(criterion.substr(1));
|
||||
}
|
||||
return arr;
|
||||
}, []);
|
||||
if (!negGlobs.length || !micromatch.any(string, negGlobs)) {
|
||||
if (path.sep === '\\' && typeof string === 'string') {
|
||||
altString = normalize(string);
|
||||
altString = altString === string ? null : altString;
|
||||
if (altString) altValue = [altString].concat(value.slice(1));
|
||||
}
|
||||
matched = crit.slice(startIndex, endIndex).some(testCriteria);
|
||||
}
|
||||
return returnIndex === true ? matchIndex : matched;
|
||||
};
|
||||
|
||||
module.exports = anymatch;
|
47
node_modules/sane/node_modules/anymatch/package.json
generated
vendored
Normal file
47
node_modules/sane/node_modules/anymatch/package.json
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "anymatch",
|
||||
"version": "2.0.0",
|
||||
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"author": {
|
||||
"name": "Elan Shanker",
|
||||
"url": "http://github.com/es128"
|
||||
},
|
||||
"license": "ISC",
|
||||
"homepage": "https://github.com/micromatch/anymatch",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/micromatch/anymatch"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/micromatch/anymatch/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"match",
|
||||
"any",
|
||||
"string",
|
||||
"file",
|
||||
"fs",
|
||||
"list",
|
||||
"glob",
|
||||
"regex",
|
||||
"regexp",
|
||||
"regular",
|
||||
"expression",
|
||||
"function"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "istanbul cover _mocha && cat ./coverage/lcov.info | coveralls"
|
||||
},
|
||||
"dependencies": {
|
||||
"micromatch": "^3.1.4",
|
||||
"normalize-path": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.7.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.0.0"
|
||||
}
|
||||
}
|
21
node_modules/sane/node_modules/braces/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/braces/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2018, 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.
|
640
node_modules/sane/node_modules/braces/README.md
generated
vendored
Normal file
640
node_modules/sane/node_modules/braces/README.md
generated
vendored
Normal file
|
@ -0,0 +1,640 @@
|
|||
# braces [](https://www.npmjs.com/package/braces) [](https://npmjs.org/package/braces) [](https://npmjs.org/package/braces) [](https://travis-ci.org/micromatch/braces) [](https://ci.appveyor.com/project/micromatch/braces)
|
||||
|
||||
> Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.
|
||||
|
||||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save braces
|
||||
```
|
||||
|
||||
## Why use braces?
|
||||
|
||||
Brace patterns are great for matching ranges. Users (and implementors) shouldn't have to think about whether or not they will break their application (or yours) from accidentally defining an aggressive brace pattern. _Braces is the only library that offers a [solution to this problem](#performance)_.
|
||||
|
||||
* **Safe(r)**: Braces isn't vulnerable to DoS attacks like [brace-expansion](https://github.com/juliangruber/brace-expansion), [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch) (a different bug than the [other regex DoS bug](https://medium.com/node-security/minimatch-redos-vulnerability-590da24e6d3c#.jew0b6mpc)).
|
||||
* **Accurate**: complete support for the [Bash 4.3 Brace Expansion](www.gnu.org/software/bash/) specification (passes all of the Bash braces tests)
|
||||
* **[fast and performant](#benchmarks)**: Starts fast, runs fast and [scales well](#performance) as patterns increase in complexity.
|
||||
* **Organized code base**: with parser and compiler that are eas(y|ier) to maintain and update when edge cases crop up.
|
||||
* **Well-tested**: thousands of test assertions. Passes 100% of the [minimatch](https://github.com/isaacs/minimatch) and [brace-expansion](https://github.com/juliangruber/brace-expansion) unit tests as well (as of the writing of this).
|
||||
|
||||
## Usage
|
||||
|
||||
The main export is a function that takes one or more brace `patterns` and `options`.
|
||||
|
||||
```js
|
||||
var braces = require('braces');
|
||||
braces(pattern[, options]);
|
||||
```
|
||||
|
||||
By default, braces returns an optimized regex-source string. To get an array of brace patterns, use `brace.expand()`.
|
||||
|
||||
The following section explains the difference in more detail. _(If you're curious about "why" braces does this by default, see [brace matching pitfalls](#brace-matching-pitfalls)_.
|
||||
|
||||
### Optimized vs. expanded braces
|
||||
|
||||
**Optimized**
|
||||
|
||||
By default, patterns are optimized for regex and matching:
|
||||
|
||||
```js
|
||||
console.log(braces('a/{x,y,z}/b'));
|
||||
//=> ['a/(x|y|z)/b']
|
||||
```
|
||||
|
||||
**Expanded**
|
||||
|
||||
To expand patterns the same way as Bash or [minimatch](https://github.com/isaacs/minimatch), use the [.expand](#expand) method:
|
||||
|
||||
```js
|
||||
console.log(braces.expand('a/{x,y,z}/b'));
|
||||
//=> ['a/x/b', 'a/y/b', 'a/z/b']
|
||||
```
|
||||
|
||||
Or use [options.expand](#optionsexpand):
|
||||
|
||||
```js
|
||||
console.log(braces('a/{x,y,z}/b', {expand: true}));
|
||||
//=> ['a/x/b', 'a/y/b', 'a/z/b']
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* [lists](#lists): Supports "lists": `a/{b,c}/d` => `['a/b/d', 'a/c/d']`
|
||||
* [sequences](#sequences): Supports alphabetical or numerical "sequences" (ranges): `{1..3}` => `['1', '2', '3']`
|
||||
* [steps](#steps): Supports "steps" or increments: `{2..10..2}` => `['2', '4', '6', '8', '10']`
|
||||
* [escaping](#escaping)
|
||||
* [options](#options)
|
||||
|
||||
### Lists
|
||||
|
||||
Uses [fill-range](https://github.com/jonschlinkert/fill-range) for expanding alphabetical or numeric lists:
|
||||
|
||||
```js
|
||||
console.log(braces('a/{foo,bar,baz}/*.js'));
|
||||
//=> ['a/(foo|bar|baz)/*.js']
|
||||
|
||||
console.log(braces.expand('a/{foo,bar,baz}/*.js'));
|
||||
//=> ['a/foo/*.js', 'a/bar/*.js', 'a/baz/*.js']
|
||||
```
|
||||
|
||||
### Sequences
|
||||
|
||||
Uses [fill-range](https://github.com/jonschlinkert/fill-range) for expanding alphabetical or numeric ranges (bash "sequences"):
|
||||
|
||||
```js
|
||||
console.log(braces.expand('{1..3}')); // ['1', '2', '3']
|
||||
console.log(braces.expand('a{01..03}b')); // ['a01b', 'a02b', 'a03b']
|
||||
console.log(braces.expand('a{1..3}b')); // ['a1b', 'a2b', 'a3b']
|
||||
console.log(braces.expand('{a..c}')); // ['a', 'b', 'c']
|
||||
console.log(braces.expand('foo/{a..c}')); // ['foo/a', 'foo/b', 'foo/c']
|
||||
|
||||
// supports padded ranges
|
||||
console.log(braces('a{01..03}b')); //=> [ 'a(0[1-3])b' ]
|
||||
console.log(braces('a{001..300}b')); //=> [ 'a(0{2}[1-9]|0[1-9][0-9]|[12][0-9]{2}|300)b' ]
|
||||
```
|
||||
|
||||
### Steps
|
||||
|
||||
Steps, or increments, may be used with ranges:
|
||||
|
||||
```js
|
||||
console.log(braces.expand('{2..10..2}'));
|
||||
//=> ['2', '4', '6', '8', '10']
|
||||
|
||||
console.log(braces('{2..10..2}'));
|
||||
//=> ['(2|4|6|8|10)']
|
||||
```
|
||||
|
||||
When the [.optimize](#optimize) method is used, or [options.optimize](#optionsoptimize) is set to true, sequences are passed to [to-regex-range](https://github.com/jonschlinkert/to-regex-range) for expansion.
|
||||
|
||||
### Nesting
|
||||
|
||||
Brace patterns may be nested. The results of each expanded string are not sorted, and left to right order is preserved.
|
||||
|
||||
**"Expanded" braces**
|
||||
|
||||
```js
|
||||
console.log(braces.expand('a{b,c,/{x,y}}/e'));
|
||||
//=> ['ab/e', 'ac/e', 'a/x/e', 'a/y/e']
|
||||
|
||||
console.log(braces.expand('a/{x,{1..5},y}/c'));
|
||||
//=> ['a/x/c', 'a/1/c', 'a/2/c', 'a/3/c', 'a/4/c', 'a/5/c', 'a/y/c']
|
||||
```
|
||||
|
||||
**"Optimized" braces**
|
||||
|
||||
```js
|
||||
console.log(braces('a{b,c,/{x,y}}/e'));
|
||||
//=> ['a(b|c|/(x|y))/e']
|
||||
|
||||
console.log(braces('a/{x,{1..5},y}/c'));
|
||||
//=> ['a/(x|([1-5])|y)/c']
|
||||
```
|
||||
|
||||
### Escaping
|
||||
|
||||
**Escaping braces**
|
||||
|
||||
A brace pattern will not be expanded or evaluted if _either the opening or closing brace is escaped_:
|
||||
|
||||
```js
|
||||
console.log(braces.expand('a\\{d,c,b}e'));
|
||||
//=> ['a{d,c,b}e']
|
||||
|
||||
console.log(braces.expand('a{d,c,b\\}e'));
|
||||
//=> ['a{d,c,b}e']
|
||||
```
|
||||
|
||||
**Escaping commas**
|
||||
|
||||
Commas inside braces may also be escaped:
|
||||
|
||||
```js
|
||||
console.log(braces.expand('a{b\\,c}d'));
|
||||
//=> ['a{b,c}d']
|
||||
|
||||
console.log(braces.expand('a{d\\,c,b}e'));
|
||||
//=> ['ad,ce', 'abe']
|
||||
```
|
||||
|
||||
**Single items**
|
||||
|
||||
Following bash conventions, a brace pattern is also not expanded when it contains a single character:
|
||||
|
||||
```js
|
||||
console.log(braces.expand('a{b}c'));
|
||||
//=> ['a{b}c']
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### options.maxLength
|
||||
|
||||
**Type**: `Number`
|
||||
|
||||
**Default**: `65,536`
|
||||
|
||||
**Description**: Limit the length of the input string. Useful when the input string is generated or your application allows users to pass a string, et cetera.
|
||||
|
||||
```js
|
||||
console.log(braces('a/{b,c}/d', { maxLength: 3 })); //=> throws an error
|
||||
```
|
||||
|
||||
### options.expand
|
||||
|
||||
**Type**: `Boolean`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Generate an "expanded" brace pattern (this option is unncessary with the `.expand` method, which does the same thing).
|
||||
|
||||
```js
|
||||
console.log(braces('a/{b,c}/d', {expand: true}));
|
||||
//=> [ 'a/b/d', 'a/c/d' ]
|
||||
```
|
||||
|
||||
### options.optimize
|
||||
|
||||
**Type**: `Boolean`
|
||||
|
||||
**Default**: `true`
|
||||
|
||||
**Description**: Enabled by default.
|
||||
|
||||
```js
|
||||
console.log(braces('a/{b,c}/d'));
|
||||
//=> [ 'a/(b|c)/d' ]
|
||||
```
|
||||
|
||||
### options.nodupes
|
||||
|
||||
**Type**: `Boolean`
|
||||
|
||||
**Default**: `true`
|
||||
|
||||
**Description**: Duplicates are removed by default. To keep duplicates, pass `{nodupes: false}` on the options
|
||||
|
||||
### options.rangeLimit
|
||||
|
||||
**Type**: `Number`
|
||||
|
||||
**Default**: `250`
|
||||
|
||||
**Description**: When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize) when the difference between the range minimum and range maximum exceeds the `rangeLimit`. This is to prevent huge ranges from freezing your application.
|
||||
|
||||
You can set this to any number, or change `options.rangeLimit` to `Inifinity` to disable this altogether.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
// pattern exceeds the "rangeLimit", so it's optimized automatically
|
||||
console.log(braces.expand('{1..1000}'));
|
||||
//=> ['([1-9]|[1-9][0-9]{1,2}|1000)']
|
||||
|
||||
// pattern does not exceed "rangeLimit", so it's NOT optimized
|
||||
console.log(braces.expand('{1..100}'));
|
||||
//=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100']
|
||||
```
|
||||
|
||||
### options.transform
|
||||
|
||||
**Type**: `Function`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Customize range expansion.
|
||||
|
||||
```js
|
||||
var range = braces.expand('x{a..e}y', {
|
||||
transform: function(str) {
|
||||
return 'foo' + str;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(range);
|
||||
//=> [ 'xfooay', 'xfooby', 'xfoocy', 'xfoody', 'xfooey' ]
|
||||
```
|
||||
|
||||
### options.quantifiers
|
||||
|
||||
**Type**: `Boolean`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, `a{1,3}` will match the letter `a` one to three times.
|
||||
|
||||
Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists)
|
||||
|
||||
The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) are defined in the given pattern, and not to try to expand them as lists.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
var braces = require('braces');
|
||||
console.log(braces('a/b{1,3}/{x,y,z}'));
|
||||
//=> [ 'a/b(1|3)/(x|y|z)' ]
|
||||
console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true}));
|
||||
//=> [ 'a/b{1,3}/(x|y|z)' ]
|
||||
console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true, expand: true}));
|
||||
//=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ]
|
||||
```
|
||||
|
||||
### options.unescape
|
||||
|
||||
**Type**: `Boolean`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Strip backslashes that were used for escaping from the result.
|
||||
|
||||
## What is "brace expansion"?
|
||||
|
||||
Brace expansion is a type of parameter expansion that was made popular by unix shells for generating lists of strings, as well as regex-like matching when used alongside wildcards (globs).
|
||||
|
||||
In addition to "expansion", braces are also used for matching. In other words:
|
||||
|
||||
* [brace expansion](#brace-expansion) is for generating new lists
|
||||
* [brace matching](#brace-matching) is for filtering existing lists
|
||||
|
||||
<details>
|
||||
<summary><strong>More about brace expansion</strong> (click to expand)</summary>
|
||||
|
||||
There are two main types of brace expansion:
|
||||
|
||||
1. **lists**: which are defined using comma-separated values inside curly braces: `{a,b,c}`
|
||||
2. **sequences**: which are defined using a starting value and an ending value, separated by two dots: `a{1..3}b`. Optionally, a third argument may be passed to define a "step" or increment to use: `a{1..100..10}b`. These are also sometimes referred to as "ranges".
|
||||
|
||||
Here are some example brace patterns to illustrate how they work:
|
||||
|
||||
**Sets**
|
||||
|
||||
```
|
||||
{a,b,c} => a b c
|
||||
{a,b,c}{1,2} => a1 a2 b1 b2 c1 c2
|
||||
```
|
||||
|
||||
**Sequences**
|
||||
|
||||
```
|
||||
{1..9} => 1 2 3 4 5 6 7 8 9
|
||||
{4..-4} => 4 3 2 1 0 -1 -2 -3 -4
|
||||
{1..20..3} => 1 4 7 10 13 16 19
|
||||
{a..j} => a b c d e f g h i j
|
||||
{j..a} => j i h g f e d c b a
|
||||
{a..z..3} => a d g j m p s v y
|
||||
```
|
||||
|
||||
**Combination**
|
||||
|
||||
Sets and sequences can be mixed together or used along with any other strings.
|
||||
|
||||
```
|
||||
{a,b,c}{1..3} => a1 a2 a3 b1 b2 b3 c1 c2 c3
|
||||
foo/{a,b,c}/bar => foo/a/bar foo/b/bar foo/c/bar
|
||||
```
|
||||
|
||||
The fact that braces can be "expanded" from relatively simple patterns makes them ideal for quickly generating test fixtures, file paths, and similar use cases.
|
||||
|
||||
## Brace matching
|
||||
|
||||
In addition to _expansion_, brace patterns are also useful for performing regular-expression-like matching.
|
||||
|
||||
For example, the pattern `foo/{1..3}/bar` would match any of following strings:
|
||||
|
||||
```
|
||||
foo/1/bar
|
||||
foo/2/bar
|
||||
foo/3/bar
|
||||
```
|
||||
|
||||
But not:
|
||||
|
||||
```
|
||||
baz/1/qux
|
||||
baz/2/qux
|
||||
baz/3/qux
|
||||
```
|
||||
|
||||
Braces can also be combined with [glob patterns](https://github.com/jonschlinkert/micromatch) to perform more advanced wildcard matching. For example, the pattern `*/{1..3}/*` would match any of following strings:
|
||||
|
||||
```
|
||||
foo/1/bar
|
||||
foo/2/bar
|
||||
foo/3/bar
|
||||
baz/1/qux
|
||||
baz/2/qux
|
||||
baz/3/qux
|
||||
```
|
||||
|
||||
## Brace matching pitfalls
|
||||
|
||||
Although brace patterns offer a user-friendly way of matching ranges or sets of strings, there are also some major disadvantages and potential risks you should be aware of.
|
||||
|
||||
### tldr
|
||||
|
||||
**"brace bombs"**
|
||||
|
||||
* brace expansion can eat up a huge amount of processing resources
|
||||
* as brace patterns increase _linearly in size_, the system resources required to expand the pattern increase exponentially
|
||||
* users can accidentally (or intentially) exhaust your system's resources resulting in the equivalent of a DoS attack (bonus: no programming knowledge is required!)
|
||||
|
||||
For a more detailed explanation with examples, see the [geometric complexity](#geometric-complexity) section.
|
||||
|
||||
### The solution
|
||||
|
||||
Jump to the [performance section](#performance) to see how Braces solves this problem in comparison to other libraries.
|
||||
|
||||
### Geometric complexity
|
||||
|
||||
At minimum, brace patterns with sets limited to two elements have quadradic or `O(n^2)` complexity. But the complexity of the algorithm increases exponentially as the number of sets, _and elements per set_, increases, which is `O(n^c)`.
|
||||
|
||||
For example, the following sets demonstrate quadratic (`O(n^2)`) complexity:
|
||||
|
||||
```
|
||||
{1,2}{3,4} => (2X2) => 13 14 23 24
|
||||
{1,2}{3,4}{5,6} => (2X2X2) => 135 136 145 146 235 236 245 246
|
||||
```
|
||||
|
||||
But add an element to a set, and we get a n-fold Cartesian product with `O(n^c)` complexity:
|
||||
|
||||
```
|
||||
{1,2,3}{4,5,6}{7,8,9} => (3X3X3) => 147 148 149 157 158 159 167 168 169 247 248
|
||||
249 257 258 259 267 268 269 347 348 349 357
|
||||
358 359 367 368 369
|
||||
```
|
||||
|
||||
Now, imagine how this complexity grows given that each element is a n-tuple:
|
||||
|
||||
```
|
||||
{1..100}{1..100} => (100X100) => 10,000 elements (38.4 kB)
|
||||
{1..100}{1..100}{1..100} => (100X100X100) => 1,000,000 elements (5.76 MB)
|
||||
```
|
||||
|
||||
Although these examples are clearly contrived, they demonstrate how brace patterns can quickly grow out of control.
|
||||
|
||||
**More information**
|
||||
|
||||
Interested in learning more about brace expansion?
|
||||
|
||||
* [linuxjournal/bash-brace-expansion](http://www.linuxjournal.com/content/bash-brace-expansion)
|
||||
* [rosettacode/Brace_expansion](https://rosettacode.org/wiki/Brace_expansion)
|
||||
* [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product)
|
||||
|
||||
</details>
|
||||
|
||||
## Performance
|
||||
|
||||
Braces is not only screaming fast, it's also more accurate the other brace expansion libraries.
|
||||
|
||||
### Better algorithms
|
||||
|
||||
Fortunately there is a solution to the ["brace bomb" problem](#brace-matching-pitfalls): _don't expand brace patterns into an array when they're used for matching_.
|
||||
|
||||
Instead, convert the pattern into an optimized regular expression. This is easier said than done, and braces is the only library that does this currently.
|
||||
|
||||
**The proof is in the numbers**
|
||||
|
||||
Minimatch gets exponentially slower as patterns increase in complexity, braces does not. The following results were generated using `braces()` and `minimatch.braceExpand()`, respectively.
|
||||
|
||||
| **Pattern** | **braces** | **[minimatch](https://github.com/isaacs/minimatch)** |
|
||||
| --- | --- | --- |
|
||||
| `{1..9007199254740991}`<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> | `298 B` (5ms 459μs) | N/A (freezes) |
|
||||
| `{1..1000000000000000}` | `41 B` (1ms 15μs) | N/A (freezes) |
|
||||
| `{1..100000000000000}` | `40 B` (890μs) | N/A (freezes) |
|
||||
| `{1..10000000000000}` | `39 B` (2ms 49μs) | N/A (freezes) |
|
||||
| `{1..1000000000000}` | `38 B` (608μs) | N/A (freezes) |
|
||||
| `{1..100000000000}` | `37 B` (397μs) | N/A (freezes) |
|
||||
| `{1..10000000000}` | `35 B` (983μs) | N/A (freezes) |
|
||||
| `{1..1000000000}` | `34 B` (798μs) | N/A (freezes) |
|
||||
| `{1..100000000}` | `33 B` (733μs) | N/A (freezes) |
|
||||
| `{1..10000000}` | `32 B` (5ms 632μs) | `78.89 MB` (16s 388ms 569μs) |
|
||||
| `{1..1000000}` | `31 B` (1ms 381μs) | `6.89 MB` (1s 496ms 887μs) |
|
||||
| `{1..100000}` | `30 B` (950μs) | `588.89 kB` (146ms 921μs) |
|
||||
| `{1..10000}` | `29 B` (1ms 114μs) | `48.89 kB` (14ms 187μs) |
|
||||
| `{1..1000}` | `28 B` (760μs) | `3.89 kB` (1ms 453μs) |
|
||||
| `{1..100}` | `22 B` (345μs) | `291 B` (196μs) |
|
||||
| `{1..10}` | `10 B` (533μs) | `20 B` (37μs) |
|
||||
| `{1..3}` | `7 B` (190μs) | `5 B` (27μs) |
|
||||
|
||||
### Faster algorithms
|
||||
|
||||
When you need expansion, braces is still much faster.
|
||||
|
||||
_(the following results were generated using `braces.expand()` and `minimatch.braceExpand()`, respectively)_
|
||||
|
||||
| **Pattern** | **braces** | **[minimatch](https://github.com/isaacs/minimatch)** |
|
||||
| --- | --- | --- |
|
||||
| `{1..10000000}` | `78.89 MB` (2s 698ms 642μs) | `78.89 MB` (18s 601ms 974μs) |
|
||||
| `{1..1000000}` | `6.89 MB` (458ms 576μs) | `6.89 MB` (1s 491ms 621μs) |
|
||||
| `{1..100000}` | `588.89 kB` (20ms 728μs) | `588.89 kB` (156ms 919μs) |
|
||||
| `{1..10000}` | `48.89 kB` (2ms 202μs) | `48.89 kB` (13ms 641μs) |
|
||||
| `{1..1000}` | `3.89 kB` (1ms 796μs) | `3.89 kB` (1ms 958μs) |
|
||||
| `{1..100}` | `291 B` (424μs) | `291 B` (211μs) |
|
||||
| `{1..10}` | `20 B` (487μs) | `20 B` (72μs) |
|
||||
| `{1..3}` | `5 B` (166μs) | `5 B` (27μs) |
|
||||
|
||||
If you'd like to run these comparisons yourself, see [test/support/generate.js](test/support/generate.js).
|
||||
|
||||
## Benchmarks
|
||||
|
||||
### Running benchmarks
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```bash
|
||||
npm i -d && npm benchmark
|
||||
```
|
||||
|
||||
### Latest results
|
||||
|
||||
```bash
|
||||
Benchmarking: (8 of 8)
|
||||
· combination-nested
|
||||
· combination
|
||||
· escaped
|
||||
· list-basic
|
||||
· list-multiple
|
||||
· no-braces
|
||||
· sequence-basic
|
||||
· sequence-multiple
|
||||
|
||||
# benchmark/fixtures/combination-nested.js (52 bytes)
|
||||
brace-expansion x 4,756 ops/sec ±1.09% (86 runs sampled)
|
||||
braces x 11,202,303 ops/sec ±1.06% (88 runs sampled)
|
||||
minimatch x 4,816 ops/sec ±0.99% (87 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/combination.js (51 bytes)
|
||||
brace-expansion x 625 ops/sec ±0.87% (87 runs sampled)
|
||||
braces x 11,031,884 ops/sec ±0.72% (90 runs sampled)
|
||||
minimatch x 637 ops/sec ±0.84% (88 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/escaped.js (44 bytes)
|
||||
brace-expansion x 163,325 ops/sec ±1.05% (87 runs sampled)
|
||||
braces x 10,655,071 ops/sec ±1.22% (88 runs sampled)
|
||||
minimatch x 147,495 ops/sec ±0.96% (88 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/list-basic.js (40 bytes)
|
||||
brace-expansion x 99,726 ops/sec ±1.07% (83 runs sampled)
|
||||
braces x 10,596,584 ops/sec ±0.98% (88 runs sampled)
|
||||
minimatch x 100,069 ops/sec ±1.17% (86 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/list-multiple.js (52 bytes)
|
||||
brace-expansion x 34,348 ops/sec ±1.08% (88 runs sampled)
|
||||
braces x 9,264,131 ops/sec ±1.12% (88 runs sampled)
|
||||
minimatch x 34,893 ops/sec ±0.87% (87 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/no-braces.js (48 bytes)
|
||||
brace-expansion x 275,368 ops/sec ±1.18% (89 runs sampled)
|
||||
braces x 9,134,677 ops/sec ±0.95% (88 runs sampled)
|
||||
minimatch x 3,755,954 ops/sec ±1.13% (89 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/sequence-basic.js (41 bytes)
|
||||
brace-expansion x 5,492 ops/sec ±1.35% (87 runs sampled)
|
||||
braces x 8,485,034 ops/sec ±1.28% (89 runs sampled)
|
||||
minimatch x 5,341 ops/sec ±1.17% (87 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
|
||||
# benchmark/fixtures/sequence-multiple.js (51 bytes)
|
||||
brace-expansion x 116 ops/sec ±0.77% (77 runs sampled)
|
||||
braces x 9,445,118 ops/sec ±1.32% (84 runs sampled)
|
||||
minimatch x 109 ops/sec ±1.16% (76 runs sampled)
|
||||
|
||||
fastest is braces
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Building docs</strong></summary>
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Related projects
|
||||
|
||||
You might also be interested in these projects:
|
||||
|
||||
* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
|
||||
* [extglob](https://www.npmjs.com/package/extglob): Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob… [more](https://github.com/micromatch/extglob) | [homepage](https://github.com/micromatch/extglob "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.")
|
||||
* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`")
|
||||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
|
||||
* [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash… [more](https://github.com/micromatch/nanomatch) | [homepage](https://github.com/micromatch/nanomatch "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)")
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 188 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 4 | [doowb](https://github.com/doowb) |
|
||||
| 1 | [es128](https://github.com/es128) |
|
||||
| 1 | [eush77](https://github.com/eush77) |
|
||||
| 1 | [hemanth](https://github.com/hemanth) |
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 17, 2018._
|
||||
|
||||
<hr class="footnotes-sep">
|
||||
<section class="footnotes">
|
||||
<ol class="footnotes-list">
|
||||
<li id="fn1" class="footnote-item">this is the largest safe integer allowed in JavaScript. <a href="#fnref1" class="footnote-backref">↩</a>
|
||||
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
318
node_modules/sane/node_modules/braces/index.js
generated
vendored
Normal file
318
node_modules/sane/node_modules/braces/index.js
generated
vendored
Normal file
|
@ -0,0 +1,318 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var toRegex = require('to-regex');
|
||||
var unique = require('array-unique');
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
/**
|
||||
* Local dependencies
|
||||
*/
|
||||
|
||||
var compilers = require('./lib/compilers');
|
||||
var parsers = require('./lib/parsers');
|
||||
var Braces = require('./lib/braces');
|
||||
var utils = require('./lib/utils');
|
||||
var MAX_LENGTH = 1024 * 64;
|
||||
var cache = {};
|
||||
|
||||
/**
|
||||
* Convert the given `braces` pattern into a regex-compatible string. By default, only one string is generated for every input string. Set `options.expand` to true to return an array of patterns (similar to Bash or minimatch. Before using `options.expand`, it's recommended that you read the [performance notes](#performance)).
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* console.log(braces('{a,b,c}'));
|
||||
* //=> ['(a|b|c)']
|
||||
*
|
||||
* console.log(braces('{a,b,c}', {expand: true}));
|
||||
* //=> ['a', 'b', 'c']
|
||||
* ```
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options`
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function braces(pattern, options) {
|
||||
var key = utils.createKey(String(pattern), options);
|
||||
var arr = [];
|
||||
|
||||
var disabled = options && options.cache === false;
|
||||
if (!disabled && cache.hasOwnProperty(key)) {
|
||||
return cache[key];
|
||||
}
|
||||
|
||||
if (Array.isArray(pattern)) {
|
||||
for (var i = 0; i < pattern.length; i++) {
|
||||
arr.push.apply(arr, braces.create(pattern[i], options));
|
||||
}
|
||||
} else {
|
||||
arr = braces.create(pattern, options);
|
||||
}
|
||||
|
||||
if (options && options.nodupes === true) {
|
||||
arr = unique(arr);
|
||||
}
|
||||
|
||||
if (!disabled) {
|
||||
cache[key] = arr;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a brace pattern into an array. This method is called by the main [braces](#braces) function when `options.expand` is true. Before using this method it's recommended that you read the [performance notes](#performance)) and advantages of using [.optimize](#optimize) instead.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* console.log(braces.expand('a/{b,c}/d'));
|
||||
* //=> ['a/b/d', 'a/c/d'];
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.expand = function(pattern, options) {
|
||||
return braces.create(pattern, extend({}, options, {expand: true}));
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands a brace pattern into a regex-compatible, optimized string. This method is called by the main [braces](#braces) function by default.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* console.log(braces.expand('a/{b,c}/d'));
|
||||
* //=> ['a/(b|c)/d']
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.optimize = function(pattern, options) {
|
||||
return braces.create(pattern, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes a brace pattern and returns either an expanded array (if `options.expand` is true), a highly optimized regex-compatible string. This method is called by the main [braces](#braces) function.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
|
||||
* //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.create = function(pattern, options) {
|
||||
if (typeof pattern !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
|
||||
var maxLength = (options && options.maxLength) || MAX_LENGTH;
|
||||
if (pattern.length >= maxLength) {
|
||||
throw new Error('expected pattern to be less than ' + maxLength + ' characters');
|
||||
}
|
||||
|
||||
function create() {
|
||||
if (pattern === '' || pattern.length < 3) {
|
||||
return [pattern];
|
||||
}
|
||||
|
||||
if (utils.isEmptySets(pattern)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (utils.isQuotedString(pattern)) {
|
||||
return [pattern.slice(1, -1)];
|
||||
}
|
||||
|
||||
var proto = new Braces(options);
|
||||
var result = !options || options.expand !== true
|
||||
? proto.optimize(pattern, options)
|
||||
: proto.expand(pattern, options);
|
||||
|
||||
// get the generated pattern(s)
|
||||
var arr = result.output;
|
||||
|
||||
// filter out empty strings if specified
|
||||
if (options && options.noempty === true) {
|
||||
arr = arr.filter(Boolean);
|
||||
}
|
||||
|
||||
// filter out duplicates if specified
|
||||
if (options && options.nodupes === true) {
|
||||
arr = unique(arr);
|
||||
}
|
||||
|
||||
Object.defineProperty(arr, 'result', {
|
||||
enumerable: false,
|
||||
value: result
|
||||
});
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
return memoize('create', pattern, options, create);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a regular expression from the given string `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
*
|
||||
* console.log(braces.makeRe('id-{200..300}'));
|
||||
* //=> /^(?:id-(20[0-9]|2[1-9][0-9]|300))$/
|
||||
* ```
|
||||
* @param {String} `pattern` The pattern to convert to regex.
|
||||
* @param {Object} `options`
|
||||
* @return {RegExp}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.makeRe = function(pattern, options) {
|
||||
if (typeof pattern !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
|
||||
var maxLength = (options && options.maxLength) || MAX_LENGTH;
|
||||
if (pattern.length >= maxLength) {
|
||||
throw new Error('expected pattern to be less than ' + maxLength + ' characters');
|
||||
}
|
||||
|
||||
function makeRe() {
|
||||
var arr = braces(pattern, options);
|
||||
var opts = extend({strictErrors: false}, options);
|
||||
return toRegex(arr, opts);
|
||||
}
|
||||
|
||||
return memoize('makeRe', pattern, options, makeRe);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* var ast = braces.parse('a/{b,c}/d');
|
||||
* console.log(ast);
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // input: 'a/{b,c}/d',
|
||||
* // nodes:
|
||||
* // [ { type: 'bos', val: '' },
|
||||
* // { type: 'text', val: 'a/' },
|
||||
* // { type: 'brace',
|
||||
* // nodes:
|
||||
* // [ { type: 'brace.open', val: '{' },
|
||||
* // { type: 'text', val: 'b,c' },
|
||||
* // { type: 'brace.close', val: '}' } ] },
|
||||
* // { type: 'text', val: '/d' },
|
||||
* // { type: 'eos', val: '' } ] }
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern to parse
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an AST
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.parse = function(pattern, options) {
|
||||
var proto = new Braces(options);
|
||||
return proto.parse(pattern, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile the given `ast` or string with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* var ast = braces.parse('a/{b,c}/d');
|
||||
* console.log(braces.compile(ast));
|
||||
* // { options: { source: 'string' },
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { eos: [Function],
|
||||
* // noop: [Function],
|
||||
* // bos: [Function],
|
||||
* // brace: [Function],
|
||||
* // 'brace.open': [Function],
|
||||
* // text: [Function],
|
||||
* // 'brace.close': [Function] },
|
||||
* // output: [ 'a/(b|c)/d' ],
|
||||
* // ast:
|
||||
* // { ... },
|
||||
* // parsingErrors: [] }
|
||||
* ```
|
||||
* @param {Object|String} `ast` AST from [.parse](#parse). If a string is passed it will be parsed first.
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an object that has an `output` property with the compiled string.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.compile = function(ast, options) {
|
||||
var proto = new Braces(options);
|
||||
return proto.compile(ast, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the regex cache.
|
||||
*
|
||||
* ```js
|
||||
* braces.clearCache();
|
||||
* ```
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.clearCache = function() {
|
||||
cache = braces.cache = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Memoize a generated regex or function. A unique key is generated
|
||||
* from the method name, pattern, and user-defined options. Set
|
||||
* options.memoize to false to disable.
|
||||
*/
|
||||
|
||||
function memoize(type, pattern, options, fn) {
|
||||
var key = utils.createKey(type + ':' + pattern, options);
|
||||
var disabled = options && options.cache === false;
|
||||
if (disabled) {
|
||||
braces.clearCache();
|
||||
return fn(pattern, options);
|
||||
}
|
||||
|
||||
if (cache.hasOwnProperty(key)) {
|
||||
return cache[key];
|
||||
}
|
||||
|
||||
var res = fn(pattern, options);
|
||||
cache[key] = res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `Braces` constructor and methods
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
braces.Braces = Braces;
|
||||
braces.compilers = compilers;
|
||||
braces.parsers = parsers;
|
||||
braces.cache = cache;
|
||||
|
||||
/**
|
||||
* Expose `braces`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = braces;
|
104
node_modules/sane/node_modules/braces/lib/braces.js
generated
vendored
Normal file
104
node_modules/sane/node_modules/braces/lib/braces.js
generated
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
'use strict';
|
||||
|
||||
var extend = require('extend-shallow');
|
||||
var Snapdragon = require('snapdragon');
|
||||
var compilers = require('./compilers');
|
||||
var parsers = require('./parsers');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Customize Snapdragon parser and renderer
|
||||
*/
|
||||
|
||||
function Braces(options) {
|
||||
this.options = extend({}, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize braces
|
||||
*/
|
||||
|
||||
Braces.prototype.init = function(options) {
|
||||
if (this.isInitialized) return;
|
||||
this.isInitialized = true;
|
||||
var opts = utils.createOptions({}, this.options, options);
|
||||
this.snapdragon = this.options.snapdragon || new Snapdragon(opts);
|
||||
this.compiler = this.snapdragon.compiler;
|
||||
this.parser = this.snapdragon.parser;
|
||||
|
||||
compilers(this.snapdragon, opts);
|
||||
parsers(this.snapdragon, opts);
|
||||
|
||||
/**
|
||||
* Call Snapdragon `.parse` method. When AST is returned, we check to
|
||||
* see if any unclosed braces are left on the stack and, if so, we iterate
|
||||
* over the stack and correct the AST so that compilers are called in the correct
|
||||
* order and unbalance braces are properly escaped.
|
||||
*/
|
||||
|
||||
utils.define(this.snapdragon, 'parse', function(pattern, options) {
|
||||
var parsed = Snapdragon.prototype.parse.apply(this, arguments);
|
||||
this.parser.ast.input = pattern;
|
||||
|
||||
var stack = this.parser.stack;
|
||||
while (stack.length) {
|
||||
addParent({type: 'brace.close', val: ''}, stack.pop());
|
||||
}
|
||||
|
||||
function addParent(node, parent) {
|
||||
utils.define(node, 'parent', parent);
|
||||
parent.nodes.push(node);
|
||||
}
|
||||
|
||||
// add non-enumerable parser reference
|
||||
utils.define(parsed, 'parser', this.parser);
|
||||
return parsed;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Decorate `.parse` method
|
||||
*/
|
||||
|
||||
Braces.prototype.parse = function(ast, options) {
|
||||
if (ast && typeof ast === 'object' && ast.nodes) return ast;
|
||||
this.init(options);
|
||||
return this.snapdragon.parse(ast, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decorate `.compile` method
|
||||
*/
|
||||
|
||||
Braces.prototype.compile = function(ast, options) {
|
||||
if (typeof ast === 'string') {
|
||||
ast = this.parse(ast, options);
|
||||
} else {
|
||||
this.init(options);
|
||||
}
|
||||
return this.snapdragon.compile(ast, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expand
|
||||
*/
|
||||
|
||||
Braces.prototype.expand = function(pattern) {
|
||||
var ast = this.parse(pattern, {expand: true});
|
||||
return this.compile(ast, {expand: true});
|
||||
};
|
||||
|
||||
/**
|
||||
* Optimize
|
||||
*/
|
||||
|
||||
Braces.prototype.optimize = function(pattern) {
|
||||
var ast = this.parse(pattern, {optimize: true});
|
||||
return this.compile(ast, {optimize: true});
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `Braces`
|
||||
*/
|
||||
|
||||
module.exports = Braces;
|
282
node_modules/sane/node_modules/braces/lib/compilers.js
generated
vendored
Normal file
282
node_modules/sane/node_modules/braces/lib/compilers.js
generated
vendored
Normal file
|
@ -0,0 +1,282 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
module.exports = function(braces, options) {
|
||||
braces.compiler
|
||||
|
||||
/**
|
||||
* bos
|
||||
*/
|
||||
|
||||
.set('bos', function() {
|
||||
if (this.output) return;
|
||||
this.ast.queue = isEscaped(this.ast) ? [this.ast.val] : [];
|
||||
this.ast.count = 1;
|
||||
})
|
||||
|
||||
/**
|
||||
* Square brackets
|
||||
*/
|
||||
|
||||
.set('bracket', function(node) {
|
||||
var close = node.close;
|
||||
var open = !node.escaped ? '[' : '\\[';
|
||||
var negated = node.negated;
|
||||
var inner = node.inner;
|
||||
|
||||
inner = inner.replace(/\\(?=[\\\w]|$)/g, '\\\\');
|
||||
if (inner === ']-') {
|
||||
inner = '\\]\\-';
|
||||
}
|
||||
|
||||
if (negated && inner.indexOf('.') === -1) {
|
||||
inner += '.';
|
||||
}
|
||||
if (negated && inner.indexOf('/') === -1) {
|
||||
inner += '/';
|
||||
}
|
||||
|
||||
var val = open + negated + inner + close;
|
||||
var queue = node.parent.queue;
|
||||
var last = utils.arrayify(queue.pop());
|
||||
|
||||
queue.push(utils.join(last, val));
|
||||
queue.push.apply(queue, []);
|
||||
})
|
||||
|
||||
/**
|
||||
* Brace
|
||||
*/
|
||||
|
||||
.set('brace', function(node) {
|
||||
node.queue = isEscaped(node) ? [node.val] : [];
|
||||
node.count = 1;
|
||||
return this.mapVisit(node.nodes);
|
||||
})
|
||||
|
||||
/**
|
||||
* Open
|
||||
*/
|
||||
|
||||
.set('brace.open', function(node) {
|
||||
node.parent.open = node.val;
|
||||
})
|
||||
|
||||
/**
|
||||
* Inner
|
||||
*/
|
||||
|
||||
.set('text', function(node) {
|
||||
var queue = node.parent.queue;
|
||||
var escaped = node.escaped;
|
||||
var segs = [node.val];
|
||||
|
||||
if (node.optimize === false) {
|
||||
options = utils.extend({}, options, {optimize: false});
|
||||
}
|
||||
|
||||
if (node.multiplier > 1) {
|
||||
node.parent.count *= node.multiplier;
|
||||
}
|
||||
|
||||
if (options.quantifiers === true && utils.isQuantifier(node.val)) {
|
||||
escaped = true;
|
||||
|
||||
} else if (node.val.length > 1) {
|
||||
if (isType(node.parent, 'brace') && !isEscaped(node)) {
|
||||
var expanded = utils.expand(node.val, options);
|
||||
segs = expanded.segs;
|
||||
|
||||
if (expanded.isOptimized) {
|
||||
node.parent.isOptimized = true;
|
||||
}
|
||||
|
||||
// if nothing was expanded, we probably have a literal brace
|
||||
if (!segs.length) {
|
||||
var val = (expanded.val || node.val);
|
||||
if (options.unescape !== false) {
|
||||
// unescape unexpanded brace sequence/set separators
|
||||
val = val.replace(/\\([,.])/g, '$1');
|
||||
// strip quotes
|
||||
val = val.replace(/["'`]/g, '');
|
||||
}
|
||||
|
||||
segs = [val];
|
||||
escaped = true;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (node.val === ',') {
|
||||
if (options.expand) {
|
||||
node.parent.queue.push(['']);
|
||||
segs = [''];
|
||||
} else {
|
||||
segs = ['|'];
|
||||
}
|
||||
} else {
|
||||
escaped = true;
|
||||
}
|
||||
|
||||
if (escaped && isType(node.parent, 'brace')) {
|
||||
if (node.parent.nodes.length <= 4 && node.parent.count === 1) {
|
||||
node.parent.escaped = true;
|
||||
} else if (node.parent.length <= 3) {
|
||||
node.parent.escaped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasQueue(node.parent)) {
|
||||
node.parent.queue = segs;
|
||||
return;
|
||||
}
|
||||
|
||||
var last = utils.arrayify(queue.pop());
|
||||
if (node.parent.count > 1 && options.expand) {
|
||||
last = multiply(last, node.parent.count);
|
||||
node.parent.count = 1;
|
||||
}
|
||||
|
||||
queue.push(utils.join(utils.flatten(last), segs.shift()));
|
||||
queue.push.apply(queue, segs);
|
||||
})
|
||||
|
||||
/**
|
||||
* Close
|
||||
*/
|
||||
|
||||
.set('brace.close', function(node) {
|
||||
var queue = node.parent.queue;
|
||||
var prev = node.parent.parent;
|
||||
var last = prev.queue.pop();
|
||||
var open = node.parent.open;
|
||||
var close = node.val;
|
||||
|
||||
if (open && close && isOptimized(node, options)) {
|
||||
open = '(';
|
||||
close = ')';
|
||||
}
|
||||
|
||||
// if a close brace exists, and the previous segment is one character
|
||||
// don't wrap the result in braces or parens
|
||||
var ele = utils.last(queue);
|
||||
if (node.parent.count > 1 && options.expand) {
|
||||
ele = multiply(queue.pop(), node.parent.count);
|
||||
node.parent.count = 1;
|
||||
queue.push(ele);
|
||||
}
|
||||
|
||||
if (close && typeof ele === 'string' && ele.length === 1) {
|
||||
open = '';
|
||||
close = '';
|
||||
}
|
||||
|
||||
if ((isLiteralBrace(node, options) || noInner(node)) && !node.parent.hasEmpty) {
|
||||
queue.push(utils.join(open, queue.pop() || ''));
|
||||
queue = utils.flatten(utils.join(queue, close));
|
||||
}
|
||||
|
||||
if (typeof last === 'undefined') {
|
||||
prev.queue = [queue];
|
||||
} else {
|
||||
prev.queue.push(utils.flatten(utils.join(last, queue)));
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* eos
|
||||
*/
|
||||
|
||||
.set('eos', function(node) {
|
||||
if (this.input) return;
|
||||
|
||||
if (options.optimize !== false) {
|
||||
this.output = utils.last(utils.flatten(this.ast.queue));
|
||||
} else if (Array.isArray(utils.last(this.ast.queue))) {
|
||||
this.output = utils.flatten(this.ast.queue.pop());
|
||||
} else {
|
||||
this.output = utils.flatten(this.ast.queue);
|
||||
}
|
||||
|
||||
if (node.parent.count > 1 && options.expand) {
|
||||
this.output = multiply(this.output, node.parent.count);
|
||||
}
|
||||
|
||||
this.output = utils.arrayify(this.output);
|
||||
this.ast.queue = [];
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Multiply the segments in the current brace level
|
||||
*/
|
||||
|
||||
function multiply(queue, n, options) {
|
||||
return utils.flatten(utils.repeat(utils.arrayify(queue), n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if `node` is escaped
|
||||
*/
|
||||
|
||||
function isEscaped(node) {
|
||||
return node.escaped === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if regex parens should be used for sets. If the parent `type`
|
||||
* is not `brace`, then we're on a root node, which means we should never
|
||||
* expand segments and open/close braces should be `{}` (since this indicates
|
||||
* a brace is missing from the set)
|
||||
*/
|
||||
|
||||
function isOptimized(node, options) {
|
||||
if (node.parent.isOptimized) return true;
|
||||
return isType(node.parent, 'brace')
|
||||
&& !isEscaped(node.parent)
|
||||
&& options.expand !== true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the value in `node` should be wrapped in a literal brace.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
function isLiteralBrace(node, options) {
|
||||
return isEscaped(node.parent) || options.optimize !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `node` does not have an inner value.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
function noInner(node, type) {
|
||||
if (node.parent.queue.length === 1) {
|
||||
return true;
|
||||
}
|
||||
var nodes = node.parent.nodes;
|
||||
return nodes.length === 3
|
||||
&& isType(nodes[0], 'brace.open')
|
||||
&& !isType(nodes[1], 'text')
|
||||
&& isType(nodes[2], 'brace.close');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `node` is the given `type`
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
function isType(node, type) {
|
||||
return typeof node !== 'undefined' && node.type === type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `node` has a non-empty queue.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
function hasQueue(node) {
|
||||
return Array.isArray(node.queue) && node.queue.length;
|
||||
}
|
360
node_modules/sane/node_modules/braces/lib/parsers.js
generated
vendored
Normal file
360
node_modules/sane/node_modules/braces/lib/parsers.js
generated
vendored
Normal file
|
@ -0,0 +1,360 @@
|
|||
'use strict';
|
||||
|
||||
var Node = require('snapdragon-node');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Braces parsers
|
||||
*/
|
||||
|
||||
module.exports = function(braces, options) {
|
||||
braces.parser
|
||||
.set('bos', function() {
|
||||
if (!this.parsed) {
|
||||
this.ast = this.nodes[0] = new Node(this.ast);
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Character parsers
|
||||
*/
|
||||
|
||||
.set('escape', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^(?:\\(.)|\$\{)/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
|
||||
var node = pos(new Node({
|
||||
type: 'text',
|
||||
multiplier: 1,
|
||||
val: m[0]
|
||||
}));
|
||||
|
||||
if (node.val === '\\\\') {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (node.val === '${') {
|
||||
var str = this.input;
|
||||
var idx = -1;
|
||||
var ch;
|
||||
|
||||
while ((ch = str[++idx])) {
|
||||
this.consume(1);
|
||||
node.val += ch;
|
||||
if (ch === '\\') {
|
||||
node.val += str[++idx];
|
||||
continue;
|
||||
}
|
||||
if (ch === '}') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.unescape !== false) {
|
||||
node.val = node.val.replace(/\\([{}])/g, '$1');
|
||||
}
|
||||
|
||||
if (last.val === '"' && this.input.charAt(0) === '"') {
|
||||
last.val = node.val;
|
||||
this.consume(1);
|
||||
return;
|
||||
}
|
||||
|
||||
return concatNodes.call(this, pos, node, prev, options);
|
||||
})
|
||||
|
||||
/**
|
||||
* Brackets: "[...]" (basic, this is overridden by
|
||||
* other parsers in more advanced implementations)
|
||||
*/
|
||||
|
||||
.set('bracket', function() {
|
||||
var isInside = this.isInside('brace');
|
||||
var pos = this.position();
|
||||
var m = this.match(/^(?:\[([!^]?)([^\]]{2,}|\]-)(\]|[^*+?]+)|\[)/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var val = m[0];
|
||||
var negated = m[1] ? '^' : '';
|
||||
var inner = m[2] || '';
|
||||
var close = m[3] || '';
|
||||
|
||||
if (isInside && prev.type === 'brace') {
|
||||
prev.text = prev.text || '';
|
||||
prev.text += val;
|
||||
}
|
||||
|
||||
var esc = this.input.slice(0, 2);
|
||||
if (inner === '' && esc === '\\]') {
|
||||
inner += esc;
|
||||
this.consume(2);
|
||||
|
||||
var str = this.input;
|
||||
var idx = -1;
|
||||
var ch;
|
||||
|
||||
while ((ch = str[++idx])) {
|
||||
this.consume(1);
|
||||
if (ch === ']') {
|
||||
close = ch;
|
||||
break;
|
||||
}
|
||||
inner += ch;
|
||||
}
|
||||
}
|
||||
|
||||
return pos(new Node({
|
||||
type: 'bracket',
|
||||
val: val,
|
||||
escaped: close !== ']',
|
||||
negated: negated,
|
||||
inner: inner,
|
||||
close: close
|
||||
}));
|
||||
})
|
||||
|
||||
/**
|
||||
* Empty braces (we capture these early to
|
||||
* speed up processing in the compiler)
|
||||
*/
|
||||
|
||||
.set('multiplier', function() {
|
||||
var isInside = this.isInside('brace');
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\{((?:,|\{,+\})+)\}/);
|
||||
if (!m) return;
|
||||
|
||||
this.multiplier = true;
|
||||
var prev = this.prev();
|
||||
var val = m[0];
|
||||
|
||||
if (isInside && prev.type === 'brace') {
|
||||
prev.text = prev.text || '';
|
||||
prev.text += val;
|
||||
}
|
||||
|
||||
var node = pos(new Node({
|
||||
type: 'text',
|
||||
multiplier: 1,
|
||||
match: m,
|
||||
val: val
|
||||
}));
|
||||
|
||||
return concatNodes.call(this, pos, node, prev, options);
|
||||
})
|
||||
|
||||
/**
|
||||
* Open
|
||||
*/
|
||||
|
||||
.set('brace.open', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\{(?!(?:[^\\}]?|,+)\})/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
|
||||
// if the last parsed character was an extglob character
|
||||
// we need to _not optimize_ the brace pattern because
|
||||
// it might be mistaken for an extglob by a downstream parser
|
||||
if (last && last.val && isExtglobChar(last.val.slice(-1))) {
|
||||
last.optimize = false;
|
||||
}
|
||||
|
||||
var open = pos(new Node({
|
||||
type: 'brace.open',
|
||||
val: m[0]
|
||||
}));
|
||||
|
||||
var node = pos(new Node({
|
||||
type: 'brace',
|
||||
nodes: []
|
||||
}));
|
||||
|
||||
node.push(open);
|
||||
prev.push(node);
|
||||
this.push('brace', node);
|
||||
})
|
||||
|
||||
/**
|
||||
* Close
|
||||
*/
|
||||
|
||||
.set('brace.close', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\}/);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
var brace = this.pop('brace');
|
||||
var node = pos(new Node({
|
||||
type: 'brace.close',
|
||||
val: m[0]
|
||||
}));
|
||||
|
||||
if (!this.isType(brace, 'brace')) {
|
||||
if (this.options.strict) {
|
||||
throw new Error('missing opening "{"');
|
||||
}
|
||||
node.type = 'text';
|
||||
node.multiplier = 0;
|
||||
node.escaped = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
if (last.text) {
|
||||
var lastNode = utils.last(last.nodes);
|
||||
if (lastNode.val === ')' && /[!@*?+]\(/.test(last.text)) {
|
||||
var open = last.nodes[0];
|
||||
var text = last.nodes[1];
|
||||
if (open.type === 'brace.open' && text && text.type === 'text') {
|
||||
text.optimize = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (brace.nodes.length > 2) {
|
||||
var first = brace.nodes[1];
|
||||
if (first.type === 'text' && first.val === ',') {
|
||||
brace.nodes.splice(1, 1);
|
||||
brace.nodes.push(first);
|
||||
}
|
||||
}
|
||||
|
||||
brace.push(node);
|
||||
})
|
||||
|
||||
/**
|
||||
* Capture boundary characters
|
||||
*/
|
||||
|
||||
.set('boundary', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^[$^](?!\{)/);
|
||||
if (!m) return;
|
||||
return pos(new Node({
|
||||
type: 'text',
|
||||
val: m[0]
|
||||
}));
|
||||
})
|
||||
|
||||
/**
|
||||
* One or zero, non-comma characters wrapped in braces
|
||||
*/
|
||||
|
||||
.set('nobrace', function() {
|
||||
var isInside = this.isInside('brace');
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\{[^,]?\}/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var val = m[0];
|
||||
|
||||
if (isInside && prev.type === 'brace') {
|
||||
prev.text = prev.text || '';
|
||||
prev.text += val;
|
||||
}
|
||||
|
||||
return pos(new Node({
|
||||
type: 'text',
|
||||
multiplier: 0,
|
||||
val: val
|
||||
}));
|
||||
})
|
||||
|
||||
/**
|
||||
* Text
|
||||
*/
|
||||
|
||||
.set('text', function() {
|
||||
var isInside = this.isInside('brace');
|
||||
var pos = this.position();
|
||||
var m = this.match(/^((?!\\)[^${}[\]])+/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var val = m[0];
|
||||
|
||||
if (isInside && prev.type === 'brace') {
|
||||
prev.text = prev.text || '';
|
||||
prev.text += val;
|
||||
}
|
||||
|
||||
var node = pos(new Node({
|
||||
type: 'text',
|
||||
multiplier: 1,
|
||||
val: val
|
||||
}));
|
||||
|
||||
return concatNodes.call(this, pos, node, prev, options);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the character is an extglob character.
|
||||
*/
|
||||
|
||||
function isExtglobChar(ch) {
|
||||
return ch === '!' || ch === '@' || ch === '*' || ch === '?' || ch === '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine text nodes, and calculate empty sets (`{,,}`)
|
||||
* @param {Function} `pos` Function to calculate node position
|
||||
* @param {Object} `node` AST node
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
function concatNodes(pos, node, parent, options) {
|
||||
node.orig = node.val;
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
var isEscaped = false;
|
||||
|
||||
if (node.val.length > 1) {
|
||||
var a = node.val.charAt(0);
|
||||
var b = node.val.slice(-1);
|
||||
|
||||
isEscaped = (a === '"' && b === '"')
|
||||
|| (a === "'" && b === "'")
|
||||
|| (a === '`' && b === '`');
|
||||
}
|
||||
|
||||
if (isEscaped && options.unescape !== false) {
|
||||
node.val = node.val.slice(1, node.val.length - 1);
|
||||
node.escaped = true;
|
||||
}
|
||||
|
||||
if (node.match) {
|
||||
var match = node.match[1];
|
||||
if (!match || match.indexOf('}') === -1) {
|
||||
match = node.match[0];
|
||||
}
|
||||
|
||||
// replace each set with a single ","
|
||||
var val = match.replace(/\{/g, ',').replace(/\}/g, '');
|
||||
node.multiplier *= val.length;
|
||||
node.val = '';
|
||||
}
|
||||
|
||||
var simpleText = last.type === 'text'
|
||||
&& last.multiplier === 1
|
||||
&& node.multiplier === 1
|
||||
&& node.val;
|
||||
|
||||
if (simpleText) {
|
||||
last.val += node.val;
|
||||
return;
|
||||
}
|
||||
|
||||
prev.push(node);
|
||||
}
|
343
node_modules/sane/node_modules/braces/lib/utils.js
generated
vendored
Normal file
343
node_modules/sane/node_modules/braces/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,343 @@
|
|||
'use strict';
|
||||
|
||||
var splitString = require('split-string');
|
||||
var utils = module.exports;
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
utils.extend = require('extend-shallow');
|
||||
utils.flatten = require('arr-flatten');
|
||||
utils.isObject = require('isobject');
|
||||
utils.fillRange = require('fill-range');
|
||||
utils.repeat = require('repeat-element');
|
||||
utils.unique = require('array-unique');
|
||||
|
||||
utils.define = function(obj, key, val) {
|
||||
Object.defineProperty(obj, key, {
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: val
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given string contains only empty brace sets.
|
||||
*/
|
||||
|
||||
utils.isEmptySets = function(str) {
|
||||
return /^(?:\{,\})+$/.test(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given string contains only empty brace sets.
|
||||
*/
|
||||
|
||||
utils.isQuotedString = function(str) {
|
||||
var open = str.charAt(0);
|
||||
if (open === '\'' || open === '"' || open === '`') {
|
||||
return str.slice(-1) === open;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the key to use for memoization. The unique key is generated
|
||||
* by iterating over the options and concatenating key-value pairs
|
||||
* to the pattern string.
|
||||
*/
|
||||
|
||||
utils.createKey = function(pattern, options) {
|
||||
var id = pattern;
|
||||
if (typeof options === 'undefined') {
|
||||
return id;
|
||||
}
|
||||
var keys = Object.keys(options);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
id += ';' + key + '=' + String(options[key]);
|
||||
}
|
||||
return id;
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize options
|
||||
*/
|
||||
|
||||
utils.createOptions = function(options) {
|
||||
var opts = utils.extend.apply(null, arguments);
|
||||
if (typeof opts.expand === 'boolean') {
|
||||
opts.optimize = !opts.expand;
|
||||
}
|
||||
if (typeof opts.optimize === 'boolean') {
|
||||
opts.expand = !opts.optimize;
|
||||
}
|
||||
if (opts.optimize === true) {
|
||||
opts.makeRe = true;
|
||||
}
|
||||
return opts;
|
||||
};
|
||||
|
||||
/**
|
||||
* Join patterns in `a` to patterns in `b`
|
||||
*/
|
||||
|
||||
utils.join = function(a, b, options) {
|
||||
options = options || {};
|
||||
a = utils.arrayify(a);
|
||||
b = utils.arrayify(b);
|
||||
|
||||
if (!a.length) return b;
|
||||
if (!b.length) return a;
|
||||
|
||||
var len = a.length;
|
||||
var idx = -1;
|
||||
var arr = [];
|
||||
|
||||
while (++idx < len) {
|
||||
var val = a[idx];
|
||||
if (Array.isArray(val)) {
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
val[i] = utils.join(val[i], b, options);
|
||||
}
|
||||
arr.push(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = 0; j < b.length; j++) {
|
||||
var bval = b[j];
|
||||
|
||||
if (Array.isArray(bval)) {
|
||||
arr.push(utils.join(val, bval, options));
|
||||
} else {
|
||||
arr.push(val + bval);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Split the given string on `,` if not escaped.
|
||||
*/
|
||||
|
||||
utils.split = function(str, options) {
|
||||
var opts = utils.extend({sep: ','}, options);
|
||||
if (typeof opts.keepQuotes !== 'boolean') {
|
||||
opts.keepQuotes = true;
|
||||
}
|
||||
if (opts.unescape === false) {
|
||||
opts.keepEscaping = true;
|
||||
}
|
||||
return splitString(str, opts, utils.escapeBrackets(opts));
|
||||
};
|
||||
|
||||
/**
|
||||
* Expand ranges or sets in the given `pattern`.
|
||||
*
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options`
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
utils.expand = function(str, options) {
|
||||
var opts = utils.extend({rangeLimit: 10000}, options);
|
||||
var segs = utils.split(str, opts);
|
||||
var tok = { segs: segs };
|
||||
|
||||
if (utils.isQuotedString(str)) {
|
||||
return tok;
|
||||
}
|
||||
|
||||
if (opts.rangeLimit === true) {
|
||||
opts.rangeLimit = 10000;
|
||||
}
|
||||
|
||||
if (segs.length > 1) {
|
||||
if (opts.optimize === false) {
|
||||
tok.val = segs[0];
|
||||
return tok;
|
||||
}
|
||||
|
||||
tok.segs = utils.stringifyArray(tok.segs);
|
||||
} else if (segs.length === 1) {
|
||||
var arr = str.split('..');
|
||||
|
||||
if (arr.length === 1) {
|
||||
tok.val = tok.segs[tok.segs.length - 1] || tok.val || str;
|
||||
tok.segs = [];
|
||||
return tok;
|
||||
}
|
||||
|
||||
if (arr.length === 2 && arr[0] === arr[1]) {
|
||||
tok.escaped = true;
|
||||
tok.val = arr[0];
|
||||
tok.segs = [];
|
||||
return tok;
|
||||
}
|
||||
|
||||
if (arr.length > 1) {
|
||||
if (opts.optimize !== false) {
|
||||
opts.optimize = true;
|
||||
delete opts.expand;
|
||||
}
|
||||
|
||||
if (opts.optimize !== true) {
|
||||
var min = Math.min(arr[0], arr[1]);
|
||||
var max = Math.max(arr[0], arr[1]);
|
||||
var step = arr[2] || 1;
|
||||
|
||||
if (opts.rangeLimit !== false && ((max - min) / step >= opts.rangeLimit)) {
|
||||
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
||||
}
|
||||
}
|
||||
|
||||
arr.push(opts);
|
||||
tok.segs = utils.fillRange.apply(null, arr);
|
||||
|
||||
if (!tok.segs.length) {
|
||||
tok.escaped = true;
|
||||
tok.val = str;
|
||||
return tok;
|
||||
}
|
||||
|
||||
if (opts.optimize === true) {
|
||||
tok.segs = utils.stringifyArray(tok.segs);
|
||||
}
|
||||
|
||||
if (tok.segs === '') {
|
||||
tok.val = str;
|
||||
} else {
|
||||
tok.val = tok.segs[0];
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
} else {
|
||||
tok.val = str;
|
||||
}
|
||||
return tok;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensure commas inside brackets and parens are not split.
|
||||
* @param {Object} `tok` Token from the `split-string` module
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
||||
utils.escapeBrackets = function(options) {
|
||||
return function(tok) {
|
||||
if (tok.escaped && tok.val === 'b') {
|
||||
tok.val = '\\b';
|
||||
return;
|
||||
}
|
||||
|
||||
if (tok.val !== '(' && tok.val !== '[') return;
|
||||
var opts = utils.extend({}, options);
|
||||
var brackets = [];
|
||||
var parens = [];
|
||||
var stack = [];
|
||||
var val = tok.val;
|
||||
var str = tok.str;
|
||||
var i = tok.idx - 1;
|
||||
|
||||
while (++i < str.length) {
|
||||
var ch = str[i];
|
||||
|
||||
if (ch === '\\') {
|
||||
val += (opts.keepEscaping === false ? '' : ch) + str[++i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch === '(') {
|
||||
parens.push(ch);
|
||||
stack.push(ch);
|
||||
}
|
||||
|
||||
if (ch === '[') {
|
||||
brackets.push(ch);
|
||||
stack.push(ch);
|
||||
}
|
||||
|
||||
if (ch === ')') {
|
||||
parens.pop();
|
||||
stack.pop();
|
||||
if (!stack.length) {
|
||||
val += ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === ']') {
|
||||
brackets.pop();
|
||||
stack.pop();
|
||||
if (!stack.length) {
|
||||
val += ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
val += ch;
|
||||
}
|
||||
|
||||
tok.split = false;
|
||||
tok.val = val.slice(1);
|
||||
tok.idx = i;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given string looks like a regex quantifier
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
utils.isQuantifier = function(str) {
|
||||
return /^(?:[0-9]?,[0-9]|[0-9],)$/.test(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Cast `val` to an array.
|
||||
* @param {*} `val`
|
||||
*/
|
||||
|
||||
utils.stringifyArray = function(arr) {
|
||||
return [utils.arrayify(arr).join('|')];
|
||||
};
|
||||
|
||||
/**
|
||||
* Cast `val` to an array.
|
||||
* @param {*} `val`
|
||||
*/
|
||||
|
||||
utils.arrayify = function(arr) {
|
||||
if (typeof arr === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
if (typeof arr === 'string') {
|
||||
return [arr];
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given `str` is a non-empty string
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
utils.isString = function(str) {
|
||||
return str != null && typeof str === 'string';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the last element from `array`
|
||||
* @param {Array} `array`
|
||||
* @return {*}
|
||||
*/
|
||||
|
||||
utils.last = function(arr, n) {
|
||||
return arr[arr.length - (n || 1)];
|
||||
};
|
||||
|
||||
utils.escapeRegex = function(str) {
|
||||
return str.replace(/\\?([!^*?()[\]{}+?/])/g, '\\$1');
|
||||
};
|
21
node_modules/sane/node_modules/braces/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/braces/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-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.
|
61
node_modules/sane/node_modules/braces/node_modules/extend-shallow/README.md
generated
vendored
Normal file
61
node_modules/sane/node_modules/braces/node_modules/extend-shallow/README.md
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
# extend-shallow [](http://badge.fury.io/js/extend-shallow) [](https://travis-ci.org/jonschlinkert/extend-shallow)
|
||||
|
||||
> Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i extend-shallow --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
extend({a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
Pass an empty object to shallow clone:
|
||||
|
||||
```js
|
||||
var obj = {};
|
||||
extend(obj, {a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
|
||||
* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 29, 2015._
|
33
node_modules/sane/node_modules/braces/node_modules/extend-shallow/index.js
generated
vendored
Normal file
33
node_modules/sane/node_modules/braces/node_modules/extend-shallow/index.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
var isObject = require('is-extendable');
|
||||
|
||||
module.exports = function extend(o/*, objects*/) {
|
||||
if (!isObject(o)) { o = {}; }
|
||||
|
||||
var len = arguments.length;
|
||||
for (var i = 1; i < len; i++) {
|
||||
var obj = arguments[i];
|
||||
|
||||
if (isObject(obj)) {
|
||||
assign(o, obj);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
function assign(a, b) {
|
||||
for (var key in b) {
|
||||
if (hasOwn(b, key)) {
|
||||
a[key] = b[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `key` is an own property of `obj`.
|
||||
*/
|
||||
|
||||
function hasOwn(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
56
node_modules/sane/node_modules/braces/node_modules/extend-shallow/package.json
generated
vendored
Normal file
56
node_modules/sane/node_modules/braces/node_modules/extend-shallow/package.json
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"name": "extend-shallow",
|
||||
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
|
||||
"version": "2.0.1",
|
||||
"homepage": "https://github.com/jonschlinkert/extend-shallow",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/extend-shallow",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-extendable": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-slice": "^0.2.3",
|
||||
"benchmarked": "^0.1.4",
|
||||
"chalk": "^1.0.0",
|
||||
"for-own": "^0.1.3",
|
||||
"glob": "^5.0.12",
|
||||
"is-plain-object": "^2.0.1",
|
||||
"kind-of": "^2.0.0",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^2.2.5",
|
||||
"should": "^7.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
"assign",
|
||||
"extend",
|
||||
"javascript",
|
||||
"js",
|
||||
"keys",
|
||||
"merge",
|
||||
"obj",
|
||||
"object",
|
||||
"prop",
|
||||
"properties",
|
||||
"property",
|
||||
"props",
|
||||
"shallow",
|
||||
"util",
|
||||
"utility",
|
||||
"utils",
|
||||
"value"
|
||||
]
|
||||
}
|
108
node_modules/sane/node_modules/braces/package.json
generated
vendored
Normal file
108
node_modules/sane/node_modules/braces/package.json
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"name": "braces",
|
||||
"description": "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.",
|
||||
"version": "2.3.2",
|
||||
"homepage": "https://github.com/micromatch/braces",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"Elan Shanker (https://github.com/es128)",
|
||||
"Eugene Sharygin (https://github.com/eush77)",
|
||||
"hemanth.hm (http://h3manth.com)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "micromatch/braces",
|
||||
"bugs": {
|
||||
"url": "https://github.com/micromatch/braces/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"benchmark": "node benchmark"
|
||||
},
|
||||
"dependencies": {
|
||||
"arr-flatten": "^1.1.0",
|
||||
"array-unique": "^0.3.2",
|
||||
"extend-shallow": "^2.0.1",
|
||||
"fill-range": "^4.0.0",
|
||||
"isobject": "^3.0.1",
|
||||
"repeat-element": "^1.1.2",
|
||||
"snapdragon": "^0.8.1",
|
||||
"snapdragon-node": "^2.0.1",
|
||||
"split-string": "^3.0.2",
|
||||
"to-regex": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-cyan": "^0.1.1",
|
||||
"benchmarked": "^2.0.0",
|
||||
"brace-expansion": "^1.1.8",
|
||||
"cross-spawn": "^5.1.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-eslint": "^4.0.0",
|
||||
"gulp-format-md": "^1.0.0",
|
||||
"gulp-istanbul": "^1.1.2",
|
||||
"gulp-mocha": "^3.0.1",
|
||||
"gulp-unused": "^0.2.1",
|
||||
"is-windows": "^1.0.1",
|
||||
"minimatch": "^3.0.4",
|
||||
"mocha": "^3.2.0",
|
||||
"noncharacters": "^1.1.0",
|
||||
"text-table": "^0.2.0",
|
||||
"time-diff": "^0.3.1",
|
||||
"yargs-parser": "^8.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"alpha",
|
||||
"alphabetical",
|
||||
"bash",
|
||||
"brace",
|
||||
"braces",
|
||||
"expand",
|
||||
"expansion",
|
||||
"filepath",
|
||||
"fill",
|
||||
"fs",
|
||||
"glob",
|
||||
"globbing",
|
||||
"letter",
|
||||
"match",
|
||||
"matches",
|
||||
"matching",
|
||||
"number",
|
||||
"numerical",
|
||||
"path",
|
||||
"range",
|
||||
"ranges",
|
||||
"sh"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"expand-brackets",
|
||||
"extglob",
|
||||
"fill-range",
|
||||
"micromatch",
|
||||
"nanomatch"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
100
node_modules/sane/node_modules/cross-spawn/CHANGELOG.md
generated
vendored
Normal file
100
node_modules/sane/node_modules/cross-spawn/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
<a name="6.0.5"></a>
|
||||
## [6.0.5](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.4...v6.0.5) (2018-03-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* avoid using deprecated Buffer constructor ([#94](https://github.com/moxystudio/node-cross-spawn/issues/94)) ([d5770df](https://github.com/moxystudio/node-cross-spawn/commit/d5770df)), closes [/nodejs.org/api/deprecations.html#deprecations_dep0005](https://github.com//nodejs.org/api/deprecations.html/issues/deprecations_dep0005)
|
||||
|
||||
|
||||
|
||||
<a name="6.0.4"></a>
|
||||
## [6.0.4](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.3...v6.0.4) (2018-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix paths being incorrectly normalized on unix ([06ee3c6](https://github.com/moxystudio/node-cross-spawn/commit/06ee3c6)), closes [#90](https://github.com/moxystudio/node-cross-spawn/issues/90)
|
||||
|
||||
|
||||
|
||||
<a name="6.0.3"></a>
|
||||
## [6.0.3](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.2...v6.0.3) (2018-01-23)
|
||||
|
||||
|
||||
|
||||
<a name="6.0.2"></a>
|
||||
## [6.0.2](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.1...v6.0.2) (2018-01-23)
|
||||
|
||||
|
||||
|
||||
<a name="6.0.1"></a>
|
||||
## [6.0.1](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.0...v6.0.1) (2018-01-23)
|
||||
|
||||
|
||||
|
||||
<a name="6.0.0"></a>
|
||||
# [6.0.0](https://github.com/moxystudio/node-cross-spawn/compare/5.1.0...6.0.0) (2018-01-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix certain arguments not being correctly escaped or causing batch syntax error ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10)), closes [#82](https://github.com/moxystudio/node-cross-spawn/issues/82) [#51](https://github.com/moxystudio/node-cross-spawn/issues/51)
|
||||
* fix commands as posix relatixe paths not working correctly, e.g.: `./my-command` ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10))
|
||||
* fix `options` argument being mutated ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10))
|
||||
* fix commands resolution when PATH was actually Path ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* improve compliance with node's ENOENT errors ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10))
|
||||
* improve detection of node's shell option support ([900cf10](https://github.com/moxystudio/node-cross-spawn/commit/900cf10))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* upgrade tooling
|
||||
* upgrate project to es6 (node v4)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* remove support for older nodejs versions, only `node >= 4` is supported
|
||||
|
||||
|
||||
<a name="5.1.0"></a>
|
||||
## [5.1.0](https://github.com/moxystudio/node-cross-spawn/compare/5.0.1...5.1.0) (2017-02-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix `options.shell` support for NodeJS [v4.8](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V4.md#4.8.0)
|
||||
|
||||
|
||||
<a name="5.0.1"></a>
|
||||
## [5.0.1](https://github.com/moxystudio/node-cross-spawn/compare/5.0.0...5.0.1) (2016-11-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix `options.shell` support for NodeJS v7
|
||||
|
||||
|
||||
<a name="5.0.0"></a>
|
||||
# [5.0.0](https://github.com/moxystudio/node-cross-spawn/compare/4.0.2...5.0.0) (2016-10-30)
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
* add support for `options.shell`
|
||||
* improve parsing of shebangs by using [`shebang-command`](https://github.com/kevva/shebang-command) module
|
||||
|
||||
|
||||
## Chores
|
||||
|
||||
* refactor some code to make it more clear
|
||||
* update README caveats
|
21
node_modules/sane/node_modules/cross-spawn/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/cross-spawn/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
|
||||
|
||||
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.
|
94
node_modules/sane/node_modules/cross-spawn/README.md
generated
vendored
Normal file
94
node_modules/sane/node_modules/cross-spawn/README.md
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
# cross-spawn
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Build status][appveyor-image]][appveyor-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
|
||||
|
||||
[npm-url]:https://npmjs.org/package/cross-spawn
|
||||
[downloads-image]:http://img.shields.io/npm/dm/cross-spawn.svg
|
||||
[npm-image]:http://img.shields.io/npm/v/cross-spawn.svg
|
||||
[travis-url]:https://travis-ci.org/moxystudio/node-cross-spawn
|
||||
[travis-image]:http://img.shields.io/travis/moxystudio/node-cross-spawn/master.svg
|
||||
[appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn
|
||||
[appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn/master.svg
|
||||
[codecov-url]:https://codecov.io/gh/moxystudio/node-cross-spawn
|
||||
[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/node-cross-spawn/master.svg
|
||||
[david-dm-url]:https://david-dm.org/moxystudio/node-cross-spawn
|
||||
[david-dm-image]:https://img.shields.io/david/moxystudio/node-cross-spawn.svg
|
||||
[david-dm-dev-url]:https://david-dm.org/moxystudio/node-cross-spawn?type=dev
|
||||
[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/node-cross-spawn.svg
|
||||
[greenkeeper-image]:https://badges.greenkeeper.io/moxystudio/node-cross-spawn.svg
|
||||
[greenkeeper-url]:https://greenkeeper.io/
|
||||
|
||||
A cross platform solution to node's spawn and spawnSync.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
`$ npm install cross-spawn`
|
||||
|
||||
|
||||
## Why
|
||||
|
||||
Node has issues when using spawn on Windows:
|
||||
|
||||
- It ignores [PATHEXT](https://github.com/joyent/node/issues/2318)
|
||||
- It does not support [shebangs](https://en.wikipedia.org/wiki/Shebang_(Unix))
|
||||
- Has problems running commands with [spaces](https://github.com/nodejs/node/issues/7367)
|
||||
- Has problems running commands with posix relative paths (e.g.: `./my-folder/my-executable`)
|
||||
- Has an [issue](https://github.com/moxystudio/node-cross-spawn/issues/82) with command shims (files in `node_modules/.bin/`), where arguments with quotes and parenthesis would result in [invalid syntax error](https://github.com/moxystudio/node-cross-spawn/blob/e77b8f22a416db46b6196767bcd35601d7e11d54/test/index.test.js#L149)
|
||||
- No `options.shell` support on node `<v4.8`
|
||||
|
||||
All these issues are handled correctly by `cross-spawn`.
|
||||
There are some known modules, such as [win-spawn](https://github.com/ForbesLindesay/win-spawn), that try to solve this but they are either broken or provide faulty escaping of shell arguments.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) or [`spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), so it's a drop in replacement.
|
||||
|
||||
|
||||
```js
|
||||
const spawn = require('cross-spawn');
|
||||
|
||||
// Spawn NPM asynchronously
|
||||
const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
|
||||
|
||||
// Spawn NPM synchronously
|
||||
const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
|
||||
```
|
||||
|
||||
|
||||
## Caveats
|
||||
|
||||
### Using `options.shell` as an alternative to `cross-spawn`
|
||||
|
||||
Starting from node `v4.8`, `spawn` has a `shell` option that allows you run commands from within a shell. This new option solves
|
||||
the [PATHEXT](https://github.com/joyent/node/issues/2318) issue but:
|
||||
|
||||
- It's not supported in node `<v4.8`
|
||||
- You must manually escape the command and arguments which is very error prone, specially when passing user input
|
||||
- There are a lot of other unresolved issues from the [Why](#why) section that you must take into account
|
||||
|
||||
If you are using the `shell` option to spawn a command in a cross platform way, consider using `cross-spawn` instead. You have been warned.
|
||||
|
||||
### `options.shell` support
|
||||
|
||||
While `cross-spawn` adds support for `options.shell` in node `<v4.8`, all of its enhancements are disabled.
|
||||
|
||||
This mimics the Node.js behavior. More specifically, the command and its arguments will not be automatically escaped nor shebang support will be offered. This is by design because if you are using `options.shell` you are probably targeting a specific platform anyway and you don't want things to get into your way.
|
||||
|
||||
### Shebangs support
|
||||
|
||||
While `cross-spawn` handles shebangs on Windows, its support is limited. More specifically, it just supports `#!/usr/bin/env <program>` where `<program>` must not contain any arguments.
|
||||
If you would like to have the shebang support improved, feel free to contribute via a pull-request.
|
||||
|
||||
Remember to always test your code on Windows!
|
||||
|
||||
|
||||
## Tests
|
||||
|
||||
`$ npm test`
|
||||
`$ npm test -- --watch` during development
|
||||
|
||||
## License
|
||||
|
||||
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
39
node_modules/sane/node_modules/cross-spawn/index.js
generated
vendored
Normal file
39
node_modules/sane/node_modules/cross-spawn/index.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
const cp = require('child_process');
|
||||
const parse = require('./lib/parse');
|
||||
const enoent = require('./lib/enoent');
|
||||
|
||||
function spawn(command, args, options) {
|
||||
// Parse the arguments
|
||||
const parsed = parse(command, args, options);
|
||||
|
||||
// Spawn the child process
|
||||
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
||||
|
||||
// Hook into child process "exit" event to emit an error if the command
|
||||
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
enoent.hookChildProcess(spawned, parsed);
|
||||
|
||||
return spawned;
|
||||
}
|
||||
|
||||
function spawnSync(command, args, options) {
|
||||
// Parse the arguments
|
||||
const parsed = parse(command, args, options);
|
||||
|
||||
// Spawn the child process
|
||||
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
||||
|
||||
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = spawn;
|
||||
module.exports.spawn = spawn;
|
||||
module.exports.sync = spawnSync;
|
||||
|
||||
module.exports._parse = parse;
|
||||
module.exports._enoent = enoent;
|
59
node_modules/sane/node_modules/cross-spawn/lib/enoent.js
generated
vendored
Normal file
59
node_modules/sane/node_modules/cross-spawn/lib/enoent.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
'use strict';
|
||||
|
||||
const isWin = process.platform === 'win32';
|
||||
|
||||
function notFoundError(original, syscall) {
|
||||
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
||||
code: 'ENOENT',
|
||||
errno: 'ENOENT',
|
||||
syscall: `${syscall} ${original.command}`,
|
||||
path: original.command,
|
||||
spawnargs: original.args,
|
||||
});
|
||||
}
|
||||
|
||||
function hookChildProcess(cp, parsed) {
|
||||
if (!isWin) {
|
||||
return;
|
||||
}
|
||||
|
||||
const originalEmit = cp.emit;
|
||||
|
||||
cp.emit = function (name, arg1) {
|
||||
// If emitting "exit" event and exit code is 1, we need to check if
|
||||
// the command exists and emit an "error" instead
|
||||
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
if (name === 'exit') {
|
||||
const err = verifyENOENT(arg1, parsed, 'spawn');
|
||||
|
||||
if (err) {
|
||||
return originalEmit.call(cp, 'error', err);
|
||||
}
|
||||
}
|
||||
|
||||
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
||||
};
|
||||
}
|
||||
|
||||
function verifyENOENT(status, parsed) {
|
||||
if (isWin && status === 1 && !parsed.file) {
|
||||
return notFoundError(parsed.original, 'spawn');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function verifyENOENTSync(status, parsed) {
|
||||
if (isWin && status === 1 && !parsed.file) {
|
||||
return notFoundError(parsed.original, 'spawnSync');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hookChildProcess,
|
||||
verifyENOENT,
|
||||
verifyENOENTSync,
|
||||
notFoundError,
|
||||
};
|
125
node_modules/sane/node_modules/cross-spawn/lib/parse.js
generated
vendored
Normal file
125
node_modules/sane/node_modules/cross-spawn/lib/parse.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const niceTry = require('nice-try');
|
||||
const resolveCommand = require('./util/resolveCommand');
|
||||
const escape = require('./util/escape');
|
||||
const readShebang = require('./util/readShebang');
|
||||
const semver = require('semver');
|
||||
|
||||
const isWin = process.platform === 'win32';
|
||||
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
||||
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
||||
|
||||
// `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0
|
||||
const supportsShellOption = niceTry(() => semver.satisfies(process.version, '^4.8.0 || ^5.7.0 || >= 6.0.0', true)) || false;
|
||||
|
||||
function detectShebang(parsed) {
|
||||
parsed.file = resolveCommand(parsed);
|
||||
|
||||
const shebang = parsed.file && readShebang(parsed.file);
|
||||
|
||||
if (shebang) {
|
||||
parsed.args.unshift(parsed.file);
|
||||
parsed.command = shebang;
|
||||
|
||||
return resolveCommand(parsed);
|
||||
}
|
||||
|
||||
return parsed.file;
|
||||
}
|
||||
|
||||
function parseNonShell(parsed) {
|
||||
if (!isWin) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
// Detect & add support for shebangs
|
||||
const commandFile = detectShebang(parsed);
|
||||
|
||||
// We don't need a shell if the command filename is an executable
|
||||
const needsShell = !isExecutableRegExp.test(commandFile);
|
||||
|
||||
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
||||
// Note that `forceShell` is an hidden option used only in tests
|
||||
if (parsed.options.forceShell || needsShell) {
|
||||
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
|
||||
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
|
||||
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
|
||||
// we need to double escape them
|
||||
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
||||
|
||||
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
|
||||
// This is necessary otherwise it will always fail with ENOENT in those cases
|
||||
parsed.command = path.normalize(parsed.command);
|
||||
|
||||
// Escape command & arguments
|
||||
parsed.command = escape.command(parsed.command);
|
||||
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
||||
|
||||
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
||||
|
||||
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
||||
parsed.command = process.env.comspec || 'cmd.exe';
|
||||
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function parseShell(parsed) {
|
||||
// If node supports the shell option, there's no need to mimic its behavior
|
||||
if (supportsShellOption) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
// Mimic node shell option
|
||||
// See https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335
|
||||
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
||||
|
||||
if (isWin) {
|
||||
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
|
||||
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
||||
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
||||
} else {
|
||||
if (typeof parsed.options.shell === 'string') {
|
||||
parsed.command = parsed.options.shell;
|
||||
} else if (process.platform === 'android') {
|
||||
parsed.command = '/system/bin/sh';
|
||||
} else {
|
||||
parsed.command = '/bin/sh';
|
||||
}
|
||||
|
||||
parsed.args = ['-c', shellCommand];
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function parse(command, args, options) {
|
||||
// Normalize arguments, similar to nodejs
|
||||
if (args && !Array.isArray(args)) {
|
||||
options = args;
|
||||
args = null;
|
||||
}
|
||||
|
||||
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
||||
options = Object.assign({}, options); // Clone object to avoid changing the original
|
||||
|
||||
// Build our parsed object
|
||||
const parsed = {
|
||||
command,
|
||||
args,
|
||||
options,
|
||||
file: undefined,
|
||||
original: {
|
||||
command,
|
||||
args,
|
||||
},
|
||||
};
|
||||
|
||||
// Delegate further parsing to shell or non-shell
|
||||
return options.shell ? parseShell(parsed) : parseNonShell(parsed);
|
||||
}
|
||||
|
||||
module.exports = parse;
|
45
node_modules/sane/node_modules/cross-spawn/lib/util/escape.js
generated
vendored
Normal file
45
node_modules/sane/node_modules/cross-spawn/lib/util/escape.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
// See http://www.robvanderwoude.com/escapechars.php
|
||||
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
||||
|
||||
function escapeCommand(arg) {
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
function escapeArgument(arg, doubleEscapeMetaChars) {
|
||||
// Convert to string
|
||||
arg = `${arg}`;
|
||||
|
||||
// Algorithm below is based on https://qntm.org/cmd
|
||||
|
||||
// Sequence of backslashes followed by a double quote:
|
||||
// double up all the backslashes and escape the double quote
|
||||
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
||||
|
||||
// Sequence of backslashes followed by the end of the string
|
||||
// (which will become a double quote later):
|
||||
// double up all the backslashes
|
||||
arg = arg.replace(/(\\*)$/, '$1$1');
|
||||
|
||||
// All other backslashes occur literally
|
||||
|
||||
// Quote the whole thing:
|
||||
arg = `"${arg}"`;
|
||||
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
// Double escape meta chars if necessary
|
||||
if (doubleEscapeMetaChars) {
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
module.exports.command = escapeCommand;
|
||||
module.exports.argument = escapeArgument;
|
32
node_modules/sane/node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
32
node_modules/sane/node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const shebangCommand = require('shebang-command');
|
||||
|
||||
function readShebang(command) {
|
||||
// Read the first 150 bytes from the file
|
||||
const size = 150;
|
||||
let buffer;
|
||||
|
||||
if (Buffer.alloc) {
|
||||
// Node.js v4.5+ / v5.10+
|
||||
buffer = Buffer.alloc(size);
|
||||
} else {
|
||||
// Old Node.js API
|
||||
buffer = new Buffer(size);
|
||||
buffer.fill(0); // zero-fill
|
||||
}
|
||||
|
||||
let fd;
|
||||
|
||||
try {
|
||||
fd = fs.openSync(command, 'r');
|
||||
fs.readSync(fd, buffer, 0, size, 0);
|
||||
fs.closeSync(fd);
|
||||
} catch (e) { /* Empty */ }
|
||||
|
||||
// Attempt to extract shebang (null is returned if not a shebang)
|
||||
return shebangCommand(buffer.toString());
|
||||
}
|
||||
|
||||
module.exports = readShebang;
|
47
node_modules/sane/node_modules/cross-spawn/lib/util/resolveCommand.js
generated
vendored
Normal file
47
node_modules/sane/node_modules/cross-spawn/lib/util/resolveCommand.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const which = require('which');
|
||||
const pathKey = require('path-key')();
|
||||
|
||||
function resolveCommandAttempt(parsed, withoutPathExt) {
|
||||
const cwd = process.cwd();
|
||||
const hasCustomCwd = parsed.options.cwd != null;
|
||||
|
||||
// If a custom `cwd` was specified, we need to change the process cwd
|
||||
// because `which` will do stat calls but does not support a custom cwd
|
||||
if (hasCustomCwd) {
|
||||
try {
|
||||
process.chdir(parsed.options.cwd);
|
||||
} catch (err) {
|
||||
/* Empty */
|
||||
}
|
||||
}
|
||||
|
||||
let resolved;
|
||||
|
||||
try {
|
||||
resolved = which.sync(parsed.command, {
|
||||
path: (parsed.options.env || process.env)[pathKey],
|
||||
pathExt: withoutPathExt ? path.delimiter : undefined,
|
||||
});
|
||||
} catch (e) {
|
||||
/* Empty */
|
||||
} finally {
|
||||
process.chdir(cwd);
|
||||
}
|
||||
|
||||
// If we successfully resolved, ensure that an absolute path is returned
|
||||
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
|
||||
if (resolved) {
|
||||
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
function resolveCommand(parsed) {
|
||||
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
||||
}
|
||||
|
||||
module.exports = resolveCommand;
|
76
node_modules/sane/node_modules/cross-spawn/package.json
generated
vendored
Normal file
76
node_modules/sane/node_modules/cross-spawn/package.json
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "cross-spawn",
|
||||
"version": "6.0.5",
|
||||
"description": "Cross platform child_process#spawn and child_process#spawnSync",
|
||||
"keywords": [
|
||||
"spawn",
|
||||
"spawnSync",
|
||||
"windows",
|
||||
"cross-platform",
|
||||
"path-ext",
|
||||
"shebang",
|
||||
"cmd",
|
||||
"execute"
|
||||
],
|
||||
"author": "André Cruz <andre@moxy.studio>",
|
||||
"homepage": "https://github.com/moxystudio/node-cross-spawn",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:moxystudio/node-cross-spawn.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "jest --env node --coverage",
|
||||
"prerelease": "npm t && npm run lint",
|
||||
"release": "standard-version",
|
||||
"precommit": "lint-staged",
|
||||
"commitmsg": "commitlint -e $GIT_PARAMS"
|
||||
},
|
||||
"standard-version": {
|
||||
"scripts": {
|
||||
"posttag": "git push --follow-tags origin master && npm publish"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"nice-try": "^1.0.4",
|
||||
"path-key": "^2.0.1",
|
||||
"semver": "^5.5.0",
|
||||
"shebang-command": "^1.2.0",
|
||||
"which": "^1.2.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^6.0.0",
|
||||
"@commitlint/config-conventional": "^6.0.2",
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-jest": "^22.1.0",
|
||||
"babel-preset-moxy": "^2.2.1",
|
||||
"eslint": "^4.3.0",
|
||||
"eslint-config-moxy": "^5.0.0",
|
||||
"husky": "^0.14.3",
|
||||
"jest": "^22.0.0",
|
||||
"lint-staged": "^7.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"regenerator-runtime": "^0.11.1",
|
||||
"rimraf": "^2.6.2",
|
||||
"standard-version": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.8"
|
||||
}
|
||||
}
|
361
node_modules/sane/node_modules/execa/index.js
generated
vendored
Normal file
361
node_modules/sane/node_modules/execa/index.js
generated
vendored
Normal file
|
@ -0,0 +1,361 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const crossSpawn = require('cross-spawn');
|
||||
const stripEof = require('strip-eof');
|
||||
const npmRunPath = require('npm-run-path');
|
||||
const isStream = require('is-stream');
|
||||
const _getStream = require('get-stream');
|
||||
const pFinally = require('p-finally');
|
||||
const onExit = require('signal-exit');
|
||||
const errname = require('./lib/errname');
|
||||
const stdio = require('./lib/stdio');
|
||||
|
||||
const TEN_MEGABYTES = 1000 * 1000 * 10;
|
||||
|
||||
function handleArgs(cmd, args, opts) {
|
||||
let parsed;
|
||||
|
||||
opts = Object.assign({
|
||||
extendEnv: true,
|
||||
env: {}
|
||||
}, opts);
|
||||
|
||||
if (opts.extendEnv) {
|
||||
opts.env = Object.assign({}, process.env, opts.env);
|
||||
}
|
||||
|
||||
if (opts.__winShell === true) {
|
||||
delete opts.__winShell;
|
||||
parsed = {
|
||||
command: cmd,
|
||||
args,
|
||||
options: opts,
|
||||
file: cmd,
|
||||
original: {
|
||||
cmd,
|
||||
args
|
||||
}
|
||||
};
|
||||
} else {
|
||||
parsed = crossSpawn._parse(cmd, args, opts);
|
||||
}
|
||||
|
||||
opts = Object.assign({
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
buffer: true,
|
||||
stripEof: true,
|
||||
preferLocal: true,
|
||||
localDir: parsed.options.cwd || process.cwd(),
|
||||
encoding: 'utf8',
|
||||
reject: true,
|
||||
cleanup: true
|
||||
}, parsed.options);
|
||||
|
||||
opts.stdio = stdio(opts);
|
||||
|
||||
if (opts.preferLocal) {
|
||||
opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
|
||||
}
|
||||
|
||||
if (opts.detached) {
|
||||
// #115
|
||||
opts.cleanup = false;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32' && path.basename(parsed.command) === 'cmd.exe') {
|
||||
// #116
|
||||
parsed.args.unshift('/q');
|
||||
}
|
||||
|
||||
return {
|
||||
cmd: parsed.command,
|
||||
args: parsed.args,
|
||||
opts,
|
||||
parsed
|
||||
};
|
||||
}
|
||||
|
||||
function handleInput(spawned, input) {
|
||||
if (input === null || input === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isStream(input)) {
|
||||
input.pipe(spawned.stdin);
|
||||
} else {
|
||||
spawned.stdin.end(input);
|
||||
}
|
||||
}
|
||||
|
||||
function handleOutput(opts, val) {
|
||||
if (val && opts.stripEof) {
|
||||
val = stripEof(val);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
function handleShell(fn, cmd, opts) {
|
||||
let file = '/bin/sh';
|
||||
let args = ['-c', cmd];
|
||||
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
opts.__winShell = true;
|
||||
file = process.env.comspec || 'cmd.exe';
|
||||
args = ['/s', '/c', `"${cmd}"`];
|
||||
opts.windowsVerbatimArguments = true;
|
||||
}
|
||||
|
||||
if (opts.shell) {
|
||||
file = opts.shell;
|
||||
delete opts.shell;
|
||||
}
|
||||
|
||||
return fn(file, args, opts);
|
||||
}
|
||||
|
||||
function getStream(process, stream, {encoding, buffer, maxBuffer}) {
|
||||
if (!process[stream]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let ret;
|
||||
|
||||
if (!buffer) {
|
||||
// TODO: Use `ret = util.promisify(stream.finished)(process[stream]);` when targeting Node.js 10
|
||||
ret = new Promise((resolve, reject) => {
|
||||
process[stream]
|
||||
.once('end', resolve)
|
||||
.once('error', reject);
|
||||
});
|
||||
} else if (encoding) {
|
||||
ret = _getStream(process[stream], {
|
||||
encoding,
|
||||
maxBuffer
|
||||
});
|
||||
} else {
|
||||
ret = _getStream.buffer(process[stream], {maxBuffer});
|
||||
}
|
||||
|
||||
return ret.catch(err => {
|
||||
err.stream = stream;
|
||||
err.message = `${stream} ${err.message}`;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
function makeError(result, options) {
|
||||
const {stdout, stderr} = result;
|
||||
|
||||
let err = result.error;
|
||||
const {code, signal} = result;
|
||||
|
||||
const {parsed, joinedCmd} = options;
|
||||
const timedOut = options.timedOut || false;
|
||||
|
||||
if (!err) {
|
||||
let output = '';
|
||||
|
||||
if (Array.isArray(parsed.opts.stdio)) {
|
||||
if (parsed.opts.stdio[2] !== 'inherit') {
|
||||
output += output.length > 0 ? stderr : `\n${stderr}`;
|
||||
}
|
||||
|
||||
if (parsed.opts.stdio[1] !== 'inherit') {
|
||||
output += `\n${stdout}`;
|
||||
}
|
||||
} else if (parsed.opts.stdio !== 'inherit') {
|
||||
output = `\n${stderr}${stdout}`;
|
||||
}
|
||||
|
||||
err = new Error(`Command failed: ${joinedCmd}${output}`);
|
||||
err.code = code < 0 ? errname(code) : code;
|
||||
}
|
||||
|
||||
err.stdout = stdout;
|
||||
err.stderr = stderr;
|
||||
err.failed = true;
|
||||
err.signal = signal || null;
|
||||
err.cmd = joinedCmd;
|
||||
err.timedOut = timedOut;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
function joinCmd(cmd, args) {
|
||||
let joinedCmd = cmd;
|
||||
|
||||
if (Array.isArray(args) && args.length > 0) {
|
||||
joinedCmd += ' ' + args.join(' ');
|
||||
}
|
||||
|
||||
return joinedCmd;
|
||||
}
|
||||
|
||||
module.exports = (cmd, args, opts) => {
|
||||
const parsed = handleArgs(cmd, args, opts);
|
||||
const {encoding, buffer, maxBuffer} = parsed.opts;
|
||||
const joinedCmd = joinCmd(cmd, args);
|
||||
|
||||
let spawned;
|
||||
try {
|
||||
spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);
|
||||
} catch (err) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
let removeExitHandler;
|
||||
if (parsed.opts.cleanup) {
|
||||
removeExitHandler = onExit(() => {
|
||||
spawned.kill();
|
||||
});
|
||||
}
|
||||
|
||||
let timeoutId = null;
|
||||
let timedOut = false;
|
||||
|
||||
const cleanup = () => {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
if (removeExitHandler) {
|
||||
removeExitHandler();
|
||||
}
|
||||
};
|
||||
|
||||
if (parsed.opts.timeout > 0) {
|
||||
timeoutId = setTimeout(() => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
spawned.kill(parsed.opts.killSignal);
|
||||
}, parsed.opts.timeout);
|
||||
}
|
||||
|
||||
const processDone = new Promise(resolve => {
|
||||
spawned.on('exit', (code, signal) => {
|
||||
cleanup();
|
||||
resolve({code, signal});
|
||||
});
|
||||
|
||||
spawned.on('error', err => {
|
||||
cleanup();
|
||||
resolve({error: err});
|
||||
});
|
||||
|
||||
if (spawned.stdin) {
|
||||
spawned.stdin.on('error', err => {
|
||||
cleanup();
|
||||
resolve({error: err});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function destroy() {
|
||||
if (spawned.stdout) {
|
||||
spawned.stdout.destroy();
|
||||
}
|
||||
|
||||
if (spawned.stderr) {
|
||||
spawned.stderr.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
const handlePromise = () => pFinally(Promise.all([
|
||||
processDone,
|
||||
getStream(spawned, 'stdout', {encoding, buffer, maxBuffer}),
|
||||
getStream(spawned, 'stderr', {encoding, buffer, maxBuffer})
|
||||
]).then(arr => {
|
||||
const result = arr[0];
|
||||
result.stdout = arr[1];
|
||||
result.stderr = arr[2];
|
||||
|
||||
if (result.error || result.code !== 0 || result.signal !== null) {
|
||||
const err = makeError(result, {
|
||||
joinedCmd,
|
||||
parsed,
|
||||
timedOut
|
||||
});
|
||||
|
||||
// TODO: missing some timeout logic for killed
|
||||
// https://github.com/nodejs/node/blob/master/lib/child_process.js#L203
|
||||
// err.killed = spawned.killed || killed;
|
||||
err.killed = err.killed || spawned.killed;
|
||||
|
||||
if (!parsed.opts.reject) {
|
||||
return err;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: handleOutput(parsed.opts, result.stdout),
|
||||
stderr: handleOutput(parsed.opts, result.stderr),
|
||||
code: 0,
|
||||
failed: false,
|
||||
killed: false,
|
||||
signal: null,
|
||||
cmd: joinedCmd,
|
||||
timedOut: false
|
||||
};
|
||||
}), destroy);
|
||||
|
||||
crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
|
||||
|
||||
handleInput(spawned, parsed.opts.input);
|
||||
|
||||
spawned.then = (onfulfilled, onrejected) => handlePromise().then(onfulfilled, onrejected);
|
||||
spawned.catch = onrejected => handlePromise().catch(onrejected);
|
||||
|
||||
return spawned;
|
||||
};
|
||||
|
||||
// TODO: set `stderr: 'ignore'` when that option is implemented
|
||||
module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);
|
||||
|
||||
// TODO: set `stdout: 'ignore'` when that option is implemented
|
||||
module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);
|
||||
|
||||
module.exports.shell = (cmd, opts) => handleShell(module.exports, cmd, opts);
|
||||
|
||||
module.exports.sync = (cmd, args, opts) => {
|
||||
const parsed = handleArgs(cmd, args, opts);
|
||||
const joinedCmd = joinCmd(cmd, args);
|
||||
|
||||
if (isStream(parsed.opts.input)) {
|
||||
throw new TypeError('The `input` option cannot be a stream in sync mode');
|
||||
}
|
||||
|
||||
const result = childProcess.spawnSync(parsed.cmd, parsed.args, parsed.opts);
|
||||
result.code = result.status;
|
||||
|
||||
if (result.error || result.status !== 0 || result.signal !== null) {
|
||||
const err = makeError(result, {
|
||||
joinedCmd,
|
||||
parsed
|
||||
});
|
||||
|
||||
if (!parsed.opts.reject) {
|
||||
return err;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: handleOutput(parsed.opts, result.stdout),
|
||||
stderr: handleOutput(parsed.opts, result.stderr),
|
||||
code: 0,
|
||||
failed: false,
|
||||
signal: null,
|
||||
cmd: joinedCmd,
|
||||
timedOut: false
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, opts);
|
39
node_modules/sane/node_modules/execa/lib/errname.js
generated
vendored
Normal file
39
node_modules/sane/node_modules/execa/lib/errname.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
// Older verions of Node.js might not have `util.getSystemErrorName()`.
|
||||
// In that case, fall back to a deprecated internal.
|
||||
const util = require('util');
|
||||
|
||||
let uv;
|
||||
|
||||
if (typeof util.getSystemErrorName === 'function') {
|
||||
module.exports = util.getSystemErrorName;
|
||||
} else {
|
||||
try {
|
||||
uv = process.binding('uv');
|
||||
|
||||
if (typeof uv.errname !== 'function') {
|
||||
throw new TypeError('uv.errname is not a function');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('execa/lib/errname: unable to establish process.binding(\'uv\')', err);
|
||||
uv = null;
|
||||
}
|
||||
|
||||
module.exports = code => errname(uv, code);
|
||||
}
|
||||
|
||||
// Used for testing the fallback behavior
|
||||
module.exports.__test__ = errname;
|
||||
|
||||
function errname(uv, code) {
|
||||
if (uv) {
|
||||
return uv.errname(code);
|
||||
}
|
||||
|
||||
if (!(code < 0)) {
|
||||
throw new Error('err >= 0');
|
||||
}
|
||||
|
||||
return `Unknown system error ${code}`;
|
||||
}
|
||||
|
41
node_modules/sane/node_modules/execa/lib/stdio.js
generated
vendored
Normal file
41
node_modules/sane/node_modules/execa/lib/stdio.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
const alias = ['stdin', 'stdout', 'stderr'];
|
||||
|
||||
const hasAlias = opts => alias.some(x => Boolean(opts[x]));
|
||||
|
||||
module.exports = opts => {
|
||||
if (!opts) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (opts.stdio && hasAlias(opts)) {
|
||||
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${alias.map(x => `\`${x}\``).join(', ')}`);
|
||||
}
|
||||
|
||||
if (typeof opts.stdio === 'string') {
|
||||
return opts.stdio;
|
||||
}
|
||||
|
||||
const stdio = opts.stdio || [];
|
||||
|
||||
if (!Array.isArray(stdio)) {
|
||||
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
||||
}
|
||||
|
||||
const result = [];
|
||||
const len = Math.max(stdio.length, alias.length);
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
let value = null;
|
||||
|
||||
if (stdio[i] !== undefined) {
|
||||
value = stdio[i];
|
||||
} else if (opts[alias[i]] !== undefined) {
|
||||
value = opts[alias[i]];
|
||||
}
|
||||
|
||||
result[i] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
9
node_modules/sane/node_modules/execa/license
generated
vendored
Normal file
9
node_modules/sane/node_modules/execa/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
69
node_modules/sane/node_modules/execa/package.json
generated
vendored
Normal file
69
node_modules/sane/node_modules/execa/package.json
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "execa",
|
||||
"version": "1.0.0",
|
||||
"description": "A better `child_process`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/execa",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"keywords": [
|
||||
"exec",
|
||||
"child",
|
||||
"process",
|
||||
"execute",
|
||||
"fork",
|
||||
"execfile",
|
||||
"spawn",
|
||||
"file",
|
||||
"shell",
|
||||
"bin",
|
||||
"binary",
|
||||
"binaries",
|
||||
"npm",
|
||||
"path",
|
||||
"local"
|
||||
],
|
||||
"dependencies": {
|
||||
"cross-spawn": "^6.0.0",
|
||||
"get-stream": "^4.0.0",
|
||||
"is-stream": "^1.1.0",
|
||||
"npm-run-path": "^2.0.0",
|
||||
"p-finally": "^1.0.0",
|
||||
"signal-exit": "^3.0.0",
|
||||
"strip-eof": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"cat-names": "^1.0.2",
|
||||
"coveralls": "^3.0.1",
|
||||
"delay": "^3.0.0",
|
||||
"is-running": "^2.0.0",
|
||||
"nyc": "^13.0.1",
|
||||
"tempfile": "^2.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"text",
|
||||
"lcov"
|
||||
],
|
||||
"exclude": [
|
||||
"**/fixtures/**",
|
||||
"**/test.js",
|
||||
"**/test/**"
|
||||
]
|
||||
}
|
||||
}
|
327
node_modules/sane/node_modules/execa/readme.md
generated
vendored
Normal file
327
node_modules/sane/node_modules/execa/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,327 @@
|
|||
# execa [](https://travis-ci.org/sindresorhus/execa) [](https://ci.appveyor.com/project/sindresorhus/execa/branch/master) [](https://coveralls.io/github/sindresorhus/execa?branch=master)
|
||||
|
||||
> A better [`child_process`](https://nodejs.org/api/child_process.html)
|
||||
|
||||
|
||||
## Why
|
||||
|
||||
- Promise interface.
|
||||
- [Strips EOF](https://github.com/sindresorhus/strip-eof) from the output so you don't have to `stdout.trim()`.
|
||||
- Supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries cross-platform.
|
||||
- [Improved Windows support.](https://github.com/IndigoUnited/node-cross-spawn#why)
|
||||
- Higher max buffer. 10 MB instead of 200 KB.
|
||||
- [Executes locally installed binaries by name.](#preferlocal)
|
||||
- [Cleans up spawned processes when the parent process dies.](#cleanup)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install execa
|
||||
```
|
||||
|
||||
<a href="https://www.patreon.com/sindresorhus">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
||||
</a>
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
const {stdout} = await execa('echo', ['unicorns']);
|
||||
console.log(stdout);
|
||||
//=> 'unicorns'
|
||||
})();
|
||||
```
|
||||
|
||||
Additional examples:
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
// Pipe the child process stdout to the current stdout
|
||||
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
|
||||
|
||||
|
||||
// Run a shell command
|
||||
const {stdout} = await execa.shell('echo unicorns');
|
||||
//=> 'unicorns'
|
||||
|
||||
|
||||
// Catching an error
|
||||
try {
|
||||
await execa.shell('exit 3');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed: /bin/sh -c exit 3'
|
||||
killed: false,
|
||||
code: 3,
|
||||
signal: null,
|
||||
cmd: '/bin/sh -c exit 3',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
timedOut: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
})();
|
||||
|
||||
// Catching an error with a sync method
|
||||
try {
|
||||
execa.shellSync('exit 3');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed: /bin/sh -c exit 3'
|
||||
code: 3,
|
||||
signal: null,
|
||||
cmd: '/bin/sh -c exit 3',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
timedOut: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### execa(file, [arguments], [options])
|
||||
|
||||
Execute a file.
|
||||
|
||||
Think of this as a mix of `child_process.execFile` and `child_process.spawn`.
|
||||
|
||||
Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
||||
|
||||
### execa.stdout(file, [arguments], [options])
|
||||
|
||||
Same as `execa()`, but returns only `stdout`.
|
||||
|
||||
### execa.stderr(file, [arguments], [options])
|
||||
|
||||
Same as `execa()`, but returns only `stderr`.
|
||||
|
||||
### execa.shell(command, [options])
|
||||
|
||||
Execute a command through the system shell. Prefer `execa()` whenever possible, as it's both faster and safer.
|
||||
|
||||
Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess).
|
||||
|
||||
The `child_process` instance is enhanced to also be promise for a result object with `stdout` and `stderr` properties.
|
||||
|
||||
### execa.sync(file, [arguments], [options])
|
||||
|
||||
Execute a file synchronously.
|
||||
|
||||
Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).
|
||||
|
||||
This method throws an `Error` if the command fails.
|
||||
|
||||
### execa.shellSync(file, [options])
|
||||
|
||||
Execute a command synchronously through the system shell.
|
||||
|
||||
Returns the same result object as [`child_process.spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).
|
||||
|
||||
### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Current working directory of the child process.
|
||||
|
||||
#### env
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: `process.env`
|
||||
|
||||
Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
|
||||
|
||||
#### extendEnv
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
||||
|
||||
#### argv0
|
||||
|
||||
Type: `string`
|
||||
|
||||
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
|
||||
|
||||
#### stdio
|
||||
|
||||
Type: `string[]` `string`<br>
|
||||
Default: `pipe`
|
||||
|
||||
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
||||
|
||||
#### detached
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
||||
|
||||
#### uid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the user identity of the process.
|
||||
|
||||
#### gid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the group identity of the process.
|
||||
|
||||
#### shell
|
||||
|
||||
Type: `boolean` `string`<br>
|
||||
Default: `false`
|
||||
|
||||
If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
||||
|
||||
#### stripEof
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
[Strip EOF](https://github.com/sindresorhus/strip-eof) (last newline) from the output.
|
||||
|
||||
#### preferLocal
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Prefer locally installed binaries when looking for a binary to execute.<br>
|
||||
If you `$ npm install foo`, you can then `execa('foo')`.
|
||||
|
||||
#### localDir
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string` `Buffer` `stream.Readable`
|
||||
|
||||
Write some input to the `stdin` of your binary.<br>
|
||||
Streams are not allowed when using the synchronous methods.
|
||||
|
||||
#### reject
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
||||
|
||||
#### cleanup
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Keep track of the spawned process and `kill` it when the parent process exits.
|
||||
|
||||
#### encoding
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `utf8`
|
||||
|
||||
Specify the character encoding used to decode the `stdout` and `stderr` output.
|
||||
|
||||
#### timeout
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `0`
|
||||
|
||||
If timeout is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than timeout milliseconds.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.
|
||||
|
||||
#### maxBuffer
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `10000000` (10MB)
|
||||
|
||||
Largest amount of data in bytes allowed on `stdout` or `stderr`.
|
||||
|
||||
#### killSignal
|
||||
|
||||
Type: `string` `number`<br>
|
||||
Default: `SIGTERM`
|
||||
|
||||
Signal value to be used when the spawned process will be killed.
|
||||
|
||||
#### stdin
|
||||
|
||||
Type: `string` `number` `Stream` `undefined` `null`<br>
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stdout
|
||||
|
||||
Type: `string` `number` `Stream` `undefined` `null`<br>
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stderr
|
||||
|
||||
Type: `string` `number` `Stream` `undefined` `null`<br>
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### windowsVerbatimArguments
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
### Save and pipe output from a child process
|
||||
|
||||
Let's say you want to show the output of a child process in real-time while also saving it to a variable.
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
const getStream = require('get-stream');
|
||||
|
||||
const stream = execa('echo', ['foo']).stdout;
|
||||
|
||||
stream.pipe(process.stdout);
|
||||
|
||||
getStream(stream).then(value => {
|
||||
console.log('child output:', value);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
21
node_modules/sane/node_modules/fill-range/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/fill-range/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, 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.
|
250
node_modules/sane/node_modules/fill-range/README.md
generated
vendored
Normal file
250
node_modules/sane/node_modules/fill-range/README.md
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
# fill-range [](https://www.npmjs.com/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://travis-ci.org/jonschlinkert/fill-range)
|
||||
|
||||
> Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Examples](#examples)
|
||||
- [Options](#options)
|
||||
* [options.step](#optionsstep)
|
||||
* [options.strictRanges](#optionsstrictranges)
|
||||
* [options.stringify](#optionsstringify)
|
||||
* [options.toRegex](#optionstoregex)
|
||||
* [options.transform](#optionstransform)
|
||||
- [About](#about)
|
||||
|
||||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save fill-range
|
||||
```
|
||||
|
||||
Install with [yarn](https://yarnpkg.com):
|
||||
|
||||
```sh
|
||||
$ yarn add fill-range
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Expands numbers and letters, optionally using a `step` as the last argument. _(Numbers may be defined as JavaScript numbers or strings)_.
|
||||
|
||||
```js
|
||||
var fill = require('fill-range');
|
||||
fill(from, to[, step, options]);
|
||||
|
||||
// examples
|
||||
console.log(fill('1', '10')); //=> '[ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ]'
|
||||
console.log(fill('1', '10', {toRegex: true})); //=> [1-9]|10
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
* `from`: **{String|Number}** the number or letter to start with
|
||||
* `to`: **{String|Number}** the number or letter to end with
|
||||
* `step`: **{String|Number|Object|Function}** Optionally pass a [step](#optionsstep) to use.
|
||||
* `options`: **{Object|Function}**: See all available [options](#options)
|
||||
|
||||
## Examples
|
||||
|
||||
By default, an array of values is returned.
|
||||
|
||||
**Alphabetical ranges**
|
||||
|
||||
```js
|
||||
console.log(fill('a', 'e')); //=> ['a', 'b', 'c', 'd', 'e']
|
||||
console.log(fill('A', 'E')); //=> [ 'A', 'B', 'C', 'D', 'E' ]
|
||||
```
|
||||
|
||||
**Numerical ranges**
|
||||
|
||||
Numbers can be defined as actual numbers or strings.
|
||||
|
||||
```js
|
||||
console.log(fill(1, 5)); //=> [ 1, 2, 3, 4, 5 ]
|
||||
console.log(fill('1', '5')); //=> [ 1, 2, 3, 4, 5 ]
|
||||
```
|
||||
|
||||
**Negative ranges**
|
||||
|
||||
Numbers can be defined as actual numbers or strings.
|
||||
|
||||
```js
|
||||
console.log(fill('-5', '-1')); //=> [ '-5', '-4', '-3', '-2', '-1' ]
|
||||
console.log(fill('-5', '5')); //=> [ '-5', '-4', '-3', '-2', '-1', '0', '1', '2', '3', '4', '5' ]
|
||||
```
|
||||
|
||||
**Steps (increments)**
|
||||
|
||||
```js
|
||||
// numerical ranges with increments
|
||||
console.log(fill('0', '25', 4)); //=> [ '0', '4', '8', '12', '16', '20', '24' ]
|
||||
console.log(fill('0', '25', 5)); //=> [ '0', '5', '10', '15', '20', '25' ]
|
||||
console.log(fill('0', '25', 6)); //=> [ '0', '6', '12', '18', '24' ]
|
||||
|
||||
// alphabetical ranges with increments
|
||||
console.log(fill('a', 'z', 4)); //=> [ 'a', 'e', 'i', 'm', 'q', 'u', 'y' ]
|
||||
console.log(fill('a', 'z', 5)); //=> [ 'a', 'f', 'k', 'p', 'u', 'z' ]
|
||||
console.log(fill('a', 'z', 6)); //=> [ 'a', 'g', 'm', 's', 'y' ]
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### options.step
|
||||
|
||||
**Type**: `number` (formatted as a string or number)
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: The increment to use for the range. Can be used with letters or numbers.
|
||||
|
||||
**Example(s)**
|
||||
|
||||
```js
|
||||
// numbers
|
||||
console.log(fill('1', '10', 2)); //=> [ '1', '3', '5', '7', '9' ]
|
||||
console.log(fill('1', '10', 3)); //=> [ '1', '4', '7', '10' ]
|
||||
console.log(fill('1', '10', 4)); //=> [ '1', '5', '9' ]
|
||||
|
||||
// letters
|
||||
console.log(fill('a', 'z', 5)); //=> [ 'a', 'f', 'k', 'p', 'u', 'z' ]
|
||||
console.log(fill('a', 'z', 7)); //=> [ 'a', 'h', 'o', 'v' ]
|
||||
console.log(fill('a', 'z', 9)); //=> [ 'a', 'j', 's' ]
|
||||
```
|
||||
|
||||
### options.strictRanges
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Default**: `false`
|
||||
|
||||
**Description**: By default, `null` is returned when an invalid range is passed. Enable this option to throw a `RangeError` on invalid ranges.
|
||||
|
||||
**Example(s)**
|
||||
|
||||
The following are all invalid:
|
||||
|
||||
```js
|
||||
fill('1.1', '2'); // decimals not supported in ranges
|
||||
fill('a', '2'); // incompatible range values
|
||||
fill(1, 10, 'foo'); // invalid "step" argument
|
||||
```
|
||||
|
||||
### options.stringify
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Cast all returned values to strings. By default, integers are returned as numbers.
|
||||
|
||||
**Example(s)**
|
||||
|
||||
```js
|
||||
console.log(fill(1, 5)); //=> [ 1, 2, 3, 4, 5 ]
|
||||
console.log(fill(1, 5, {stringify: true})); //=> [ '1', '2', '3', '4', '5' ]
|
||||
```
|
||||
|
||||
### options.toRegex
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Create a regex-compatible source string, instead of expanding values to an array.
|
||||
|
||||
**Example(s)**
|
||||
|
||||
```js
|
||||
// alphabetical range
|
||||
console.log(fill('a', 'e', {toRegex: true})); //=> '[a-e]'
|
||||
// alphabetical with step
|
||||
console.log(fill('a', 'z', 3, {toRegex: true})); //=> 'a|d|g|j|m|p|s|v|y'
|
||||
// numerical range
|
||||
console.log(fill('1', '100', {toRegex: true})); //=> '[1-9]|[1-9][0-9]|100'
|
||||
// numerical range with zero padding
|
||||
console.log(fill('000001', '100000', {toRegex: true}));
|
||||
//=> '0{5}[1-9]|0{4}[1-9][0-9]|0{3}[1-9][0-9]{2}|0{2}[1-9][0-9]{3}|0[1-9][0-9]{4}|100000'
|
||||
```
|
||||
|
||||
### options.transform
|
||||
|
||||
**Type**: `function`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
**Description**: Customize each value in the returned array (or [string](#optionstoRegex)). _(you can also pass this function as the last argument to `fill()`)_.
|
||||
|
||||
**Example(s)**
|
||||
|
||||
```js
|
||||
// increase padding by two
|
||||
var arr = fill('01', '05', function(val, a, b, step, idx, arr, options) {
|
||||
return repeat('0', (options.maxLength + 2) - val.length) + val;
|
||||
});
|
||||
|
||||
console.log(arr);
|
||||
//=> ['0001', '0002', '0003', '0004', '0005']
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [braces](https://www.npmjs.com/package/braces): Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) | [homepage](https://github.com/jonschlinkert/braces "Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces specification, without sacrificing speed.")
|
||||
* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range) | [homepage](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.")
|
||||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
|
||||
* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/jonschlinkert/to-regex-range) | [homepage](https://github.com/jonschlinkert/to-regex-range "Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.87 million test assertions.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 103 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [paulmillr](https://github.com/paulmillr) |
|
||||
| 1 | [edorivai](https://github.com/edorivai) |
|
||||
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 23, 2017._
|
208
node_modules/sane/node_modules/fill-range/index.js
generated
vendored
Normal file
208
node_modules/sane/node_modules/fill-range/index.js
generated
vendored
Normal file
|
@ -0,0 +1,208 @@
|
|||
/*!
|
||||
* fill-range <https://github.com/jonschlinkert/fill-range>
|
||||
*
|
||||
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var isNumber = require('is-number');
|
||||
var extend = require('extend-shallow');
|
||||
var repeat = require('repeat-string');
|
||||
var toRegex = require('to-regex-range');
|
||||
|
||||
/**
|
||||
* Return a range of numbers or letters.
|
||||
*
|
||||
* @param {String} `start` Start of the range
|
||||
* @param {String} `stop` End of the range
|
||||
* @param {String} `step` Increment or decrement to use.
|
||||
* @param {Function} `fn` Custom function to modify each element in the range.
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
function fillRange(start, stop, step, options) {
|
||||
if (typeof start === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (typeof stop === 'undefined' || start === stop) {
|
||||
// special case, for handling negative zero
|
||||
var isString = typeof start === 'string';
|
||||
if (isNumber(start) && !toNumber(start)) {
|
||||
return [isString ? '0' : 0];
|
||||
}
|
||||
return [start];
|
||||
}
|
||||
|
||||
if (typeof step !== 'number' && typeof step !== 'string') {
|
||||
options = step;
|
||||
step = undefined;
|
||||
}
|
||||
|
||||
if (typeof options === 'function') {
|
||||
options = { transform: options };
|
||||
}
|
||||
|
||||
var opts = extend({step: step}, options);
|
||||
if (opts.step && !isValidNumber(opts.step)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new TypeError('expected options.step to be a number');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
opts.isNumber = isValidNumber(start) && isValidNumber(stop);
|
||||
if (!opts.isNumber && !isValid(start, stop)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new RangeError('invalid range arguments: ' + util.inspect([start, stop]));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
opts.isPadded = isPadded(start) || isPadded(stop);
|
||||
opts.toString = opts.stringify
|
||||
|| typeof opts.step === 'string'
|
||||
|| typeof start === 'string'
|
||||
|| typeof stop === 'string'
|
||||
|| !opts.isNumber;
|
||||
|
||||
if (opts.isPadded) {
|
||||
opts.maxLength = Math.max(String(start).length, String(stop).length);
|
||||
}
|
||||
|
||||
// support legacy minimatch/fill-range options
|
||||
if (typeof opts.optimize === 'boolean') opts.toRegex = opts.optimize;
|
||||
if (typeof opts.makeRe === 'boolean') opts.toRegex = opts.makeRe;
|
||||
return expand(start, stop, opts);
|
||||
}
|
||||
|
||||
function expand(start, stop, options) {
|
||||
var a = options.isNumber ? toNumber(start) : start.charCodeAt(0);
|
||||
var b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0);
|
||||
|
||||
var step = Math.abs(toNumber(options.step)) || 1;
|
||||
if (options.toRegex && step === 1) {
|
||||
return toRange(a, b, start, stop, options);
|
||||
}
|
||||
|
||||
var zero = {greater: [], lesser: []};
|
||||
var asc = a < b;
|
||||
var arr = new Array(Math.round((asc ? b - a : a - b) / step));
|
||||
var idx = 0;
|
||||
|
||||
while (asc ? a <= b : a >= b) {
|
||||
var val = options.isNumber ? a : String.fromCharCode(a);
|
||||
if (options.toRegex && (val >= 0 || !options.isNumber)) {
|
||||
zero.greater.push(val);
|
||||
} else {
|
||||
zero.lesser.push(Math.abs(val));
|
||||
}
|
||||
|
||||
if (options.isPadded) {
|
||||
val = zeros(val, options);
|
||||
}
|
||||
|
||||
if (options.toString) {
|
||||
val = String(val);
|
||||
}
|
||||
|
||||
if (typeof options.transform === 'function') {
|
||||
arr[idx++] = options.transform(val, a, b, step, idx, arr, options);
|
||||
} else {
|
||||
arr[idx++] = val;
|
||||
}
|
||||
|
||||
if (asc) {
|
||||
a += step;
|
||||
} else {
|
||||
a -= step;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return toSequence(arr, zero, options);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function toRange(a, b, start, stop, options) {
|
||||
if (options.isPadded) {
|
||||
return toRegex(start, stop, options);
|
||||
}
|
||||
|
||||
if (options.isNumber) {
|
||||
return toRegex(Math.min(a, b), Math.max(a, b), options);
|
||||
}
|
||||
|
||||
var start = String.fromCharCode(Math.min(a, b));
|
||||
var stop = String.fromCharCode(Math.max(a, b));
|
||||
return '[' + start + '-' + stop + ']';
|
||||
}
|
||||
|
||||
function toSequence(arr, zeros, options) {
|
||||
var greater = '', lesser = '';
|
||||
if (zeros.greater.length) {
|
||||
greater = zeros.greater.join('|');
|
||||
}
|
||||
if (zeros.lesser.length) {
|
||||
lesser = '-(' + zeros.lesser.join('|') + ')';
|
||||
}
|
||||
var res = greater && lesser
|
||||
? greater + '|' + lesser
|
||||
: greater || lesser;
|
||||
|
||||
if (options.capture) {
|
||||
return '(' + res + ')';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function zeros(val, options) {
|
||||
if (options.isPadded) {
|
||||
var str = String(val);
|
||||
var len = str.length;
|
||||
var dash = '';
|
||||
if (str.charAt(0) === '-') {
|
||||
dash = '-';
|
||||
str = str.slice(1);
|
||||
}
|
||||
var diff = options.maxLength - len;
|
||||
var pad = repeat('0', diff);
|
||||
val = (dash + pad + str);
|
||||
}
|
||||
if (options.stringify) {
|
||||
return String(val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function toNumber(val) {
|
||||
return Number(val) || 0;
|
||||
}
|
||||
|
||||
function isPadded(str) {
|
||||
return /^-?0\d/.test(str);
|
||||
}
|
||||
|
||||
function isValid(min, max) {
|
||||
return (isValidNumber(min) || isValidLetter(min))
|
||||
&& (isValidNumber(max) || isValidLetter(max));
|
||||
}
|
||||
|
||||
function isValidLetter(ch) {
|
||||
return typeof ch === 'string' && ch.length === 1 && /^\w+$/.test(ch);
|
||||
}
|
||||
|
||||
function isValidNumber(n) {
|
||||
return isNumber(n) && !/\./.test(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `fillRange`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = fillRange;
|
21
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-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.
|
61
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/README.md
generated
vendored
Normal file
61
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/README.md
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
# extend-shallow [](http://badge.fury.io/js/extend-shallow) [](https://travis-ci.org/jonschlinkert/extend-shallow)
|
||||
|
||||
> Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i extend-shallow --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
extend({a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
Pass an empty object to shallow clone:
|
||||
|
||||
```js
|
||||
var obj = {};
|
||||
extend(obj, {a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
|
||||
* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 29, 2015._
|
33
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/index.js
generated
vendored
Normal file
33
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/index.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
var isObject = require('is-extendable');
|
||||
|
||||
module.exports = function extend(o/*, objects*/) {
|
||||
if (!isObject(o)) { o = {}; }
|
||||
|
||||
var len = arguments.length;
|
||||
for (var i = 1; i < len; i++) {
|
||||
var obj = arguments[i];
|
||||
|
||||
if (isObject(obj)) {
|
||||
assign(o, obj);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
function assign(a, b) {
|
||||
for (var key in b) {
|
||||
if (hasOwn(b, key)) {
|
||||
a[key] = b[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `key` is an own property of `obj`.
|
||||
*/
|
||||
|
||||
function hasOwn(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
56
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/package.json
generated
vendored
Normal file
56
node_modules/sane/node_modules/fill-range/node_modules/extend-shallow/package.json
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"name": "extend-shallow",
|
||||
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
|
||||
"version": "2.0.1",
|
||||
"homepage": "https://github.com/jonschlinkert/extend-shallow",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/extend-shallow",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-extendable": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-slice": "^0.2.3",
|
||||
"benchmarked": "^0.1.4",
|
||||
"chalk": "^1.0.0",
|
||||
"for-own": "^0.1.3",
|
||||
"glob": "^5.0.12",
|
||||
"is-plain-object": "^2.0.1",
|
||||
"kind-of": "^2.0.0",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^2.2.5",
|
||||
"should": "^7.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
"assign",
|
||||
"extend",
|
||||
"javascript",
|
||||
"js",
|
||||
"keys",
|
||||
"merge",
|
||||
"obj",
|
||||
"object",
|
||||
"prop",
|
||||
"properties",
|
||||
"property",
|
||||
"props",
|
||||
"shallow",
|
||||
"util",
|
||||
"utility",
|
||||
"utils",
|
||||
"value"
|
||||
]
|
||||
}
|
82
node_modules/sane/node_modules/fill-range/package.json
generated
vendored
Normal file
82
node_modules/sane/node_modules/fill-range/package.json
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"name": "fill-range",
|
||||
"description": "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`",
|
||||
"version": "4.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/fill-range",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"<wtgtybhertgeghgtwtg@gmail.com> (https://github.com/wtgtybhertgeghgtwtg)",
|
||||
"Edo Rivai <edo.rivai@gmail.com> (edo.rivai.nl)",
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
|
||||
"Paul Miller <paul+gh@paulmillr.com> (paulmillr.com)"
|
||||
],
|
||||
"repository": "jonschlinkert/fill-range",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/fill-range/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"extend-shallow": "^2.0.1",
|
||||
"is-number": "^3.0.0",
|
||||
"repeat-string": "^1.6.1",
|
||||
"to-regex-range": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-cyan": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"alpha",
|
||||
"alphabetical",
|
||||
"array",
|
||||
"bash",
|
||||
"brace",
|
||||
"expand",
|
||||
"expansion",
|
||||
"fill",
|
||||
"glob",
|
||||
"match",
|
||||
"matches",
|
||||
"matching",
|
||||
"number",
|
||||
"numerical",
|
||||
"range",
|
||||
"ranges",
|
||||
"regex",
|
||||
"sh"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"braces",
|
||||
"expand-range",
|
||||
"micromatch",
|
||||
"to-regex-range"
|
||||
]
|
||||
},
|
||||
"toc": true,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
51
node_modules/sane/node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
51
node_modules/sane/node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
const {PassThrough} = require('stream');
|
||||
|
||||
module.exports = options => {
|
||||
options = Object.assign({}, options);
|
||||
|
||||
const {array} = options;
|
||||
let {encoding} = options;
|
||||
const buffer = encoding === 'buffer';
|
||||
let objectMode = false;
|
||||
|
||||
if (array) {
|
||||
objectMode = !(encoding || buffer);
|
||||
} else {
|
||||
encoding = encoding || 'utf8';
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
let len = 0;
|
||||
const ret = [];
|
||||
const stream = new PassThrough({objectMode});
|
||||
|
||||
if (encoding) {
|
||||
stream.setEncoding(encoding);
|
||||
}
|
||||
|
||||
stream.on('data', chunk => {
|
||||
ret.push(chunk);
|
||||
|
||||
if (objectMode) {
|
||||
len = ret.length;
|
||||
} else {
|
||||
len += chunk.length;
|
||||
}
|
||||
});
|
||||
|
||||
stream.getBufferedValue = () => {
|
||||
if (array) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
||||
};
|
||||
|
||||
stream.getBufferedLength = () => len;
|
||||
|
||||
return stream;
|
||||
};
|
50
node_modules/sane/node_modules/get-stream/index.js
generated
vendored
Normal file
50
node_modules/sane/node_modules/get-stream/index.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
const pump = require('pump');
|
||||
const bufferStream = require('./buffer-stream');
|
||||
|
||||
class MaxBufferError extends Error {
|
||||
constructor() {
|
||||
super('maxBuffer exceeded');
|
||||
this.name = 'MaxBufferError';
|
||||
}
|
||||
}
|
||||
|
||||
function getStream(inputStream, options) {
|
||||
if (!inputStream) {
|
||||
return Promise.reject(new Error('Expected a stream'));
|
||||
}
|
||||
|
||||
options = Object.assign({maxBuffer: Infinity}, options);
|
||||
|
||||
const {maxBuffer} = options;
|
||||
|
||||
let stream;
|
||||
return new Promise((resolve, reject) => {
|
||||
const rejectPromise = error => {
|
||||
if (error) { // A null check
|
||||
error.bufferedData = stream.getBufferedValue();
|
||||
}
|
||||
reject(error);
|
||||
};
|
||||
|
||||
stream = pump(inputStream, bufferStream(options), error => {
|
||||
if (error) {
|
||||
rejectPromise(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
stream.on('data', () => {
|
||||
if (stream.getBufferedLength() > maxBuffer) {
|
||||
rejectPromise(new MaxBufferError());
|
||||
}
|
||||
});
|
||||
}).then(() => stream.getBufferedValue());
|
||||
}
|
||||
|
||||
module.exports = getStream;
|
||||
module.exports.buffer = (stream, options) => getStream(stream, Object.assign({}, options, {encoding: 'buffer'}));
|
||||
module.exports.array = (stream, options) => getStream(stream, Object.assign({}, options, {array: true}));
|
||||
module.exports.MaxBufferError = MaxBufferError;
|
9
node_modules/sane/node_modules/get-stream/license
generated
vendored
Normal file
9
node_modules/sane/node_modules/get-stream/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
46
node_modules/sane/node_modules/get-stream/package.json
generated
vendored
Normal file
46
node_modules/sane/node_modules/get-stream/package.json
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "get-stream",
|
||||
"version": "4.1.0",
|
||||
"description": "Get a stream as a string, buffer, or array",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/get-stream",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"buffer-stream.js"
|
||||
],
|
||||
"keywords": [
|
||||
"get",
|
||||
"stream",
|
||||
"promise",
|
||||
"concat",
|
||||
"string",
|
||||
"text",
|
||||
"buffer",
|
||||
"read",
|
||||
"data",
|
||||
"consume",
|
||||
"readable",
|
||||
"readablestream",
|
||||
"array",
|
||||
"object"
|
||||
],
|
||||
"dependencies": {
|
||||
"pump": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"into-stream": "^3.0.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
123
node_modules/sane/node_modules/get-stream/readme.md
generated
vendored
Normal file
123
node_modules/sane/node_modules/get-stream/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
# get-stream [](https://travis-ci.org/sindresorhus/get-stream)
|
||||
|
||||
> Get a stream as a string, buffer, or array
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install get-stream
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const getStream = require('get-stream');
|
||||
|
||||
(async () => {
|
||||
const stream = fs.createReadStream('unicorn.txt');
|
||||
|
||||
console.log(await getStream(stream));
|
||||
/*
|
||||
,,))))))));,
|
||||
__)))))))))))))),
|
||||
\|/ -\(((((''''((((((((.
|
||||
-*-==//////(('' . `)))))),
|
||||
/|\ ))| o ;-. '((((( ,(,
|
||||
( `| / ) ;))))' ,_))^;(~
|
||||
| | | ,))((((_ _____------~~~-. %,;(;(>';'~
|
||||
o_); ; )))(((` ~---~ `:: \ %%~~)(v;(`('~
|
||||
; ''''```` `: `:::|\,__,%% );`'; ~
|
||||
| _ ) / `:|`----' `-'
|
||||
______/\/~ | / /
|
||||
/~;;.____/;;' / ___--,-( `;;;/
|
||||
/ // _;______;'------~~~~~ /;;/\ /
|
||||
// | | / ; \;;,\
|
||||
(<_ | ; /',/-----' _>
|
||||
\_| ||_ //~;~~~~~~~~~
|
||||
`\_| (,~~
|
||||
\~\
|
||||
~~
|
||||
*/
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
The methods returns a promise that resolves when the `end` event fires on the stream, indicating that there is no more data to be read. The stream is switched to flowing mode.
|
||||
|
||||
### getStream(stream, [options])
|
||||
|
||||
Get the `stream` as a string.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### encoding
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `utf8`
|
||||
|
||||
[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream.
|
||||
|
||||
##### maxBuffer
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`
|
||||
|
||||
Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected with a `getStream.MaxBufferError` error.
|
||||
|
||||
### getStream.buffer(stream, [options])
|
||||
|
||||
Get the `stream` as a buffer.
|
||||
|
||||
It honors the `maxBuffer` option as above, but it refers to byte length rather than string length.
|
||||
|
||||
### getStream.array(stream, [options])
|
||||
|
||||
Get the `stream` as an array of values.
|
||||
|
||||
It honors both the `maxBuffer` and `encoding` options. The behavior changes slightly based on the encoding chosen:
|
||||
|
||||
- When `encoding` is unset, it assumes an [object mode stream](https://nodesource.com/blog/understanding-object-streams/) and collects values emitted from `stream` unmodified. In this case `maxBuffer` refers to the number of items in the array (not the sum of their sizes).
|
||||
|
||||
- When `encoding` is set to `buffer`, it collects an array of buffers. `maxBuffer` refers to the summed byte lengths of every buffer in the array.
|
||||
|
||||
- When `encoding` is set to anything else, it collects an array of strings. `maxBuffer` refers to the summed character lengths of every string in the array.
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
If the input stream emits an `error` event, the promise will be rejected with the error. The buffered data will be attached to the `bufferedData` property of the error.
|
||||
|
||||
```js
|
||||
(async () => {
|
||||
try {
|
||||
await getStream(streamThatErrorsAtTheEnd('unicorn'));
|
||||
} catch (error) {
|
||||
console.log(error.bufferedData);
|
||||
//=> 'unicorn'
|
||||
}
|
||||
})()
|
||||
```
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### How is this different from [`concat-stream`](https://github.com/maxogden/concat-stream)?
|
||||
|
||||
This module accepts a stream instead of being one and returns a promise instead of using a callback. The API is simpler and it only supports returning a string, buffer, or array. It doesn't have a fragile type inference. You explicitly choose what you want. And it doesn't depend on the huge `readable-stream` package.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [get-stdin](https://github.com/sindresorhus/get-stdin) - Get stdin as a string or buffer
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
21
node_modules/sane/node_modules/is-extendable/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/is-extendable/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The 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.
|
72
node_modules/sane/node_modules/is-extendable/README.md
generated
vendored
Normal file
72
node_modules/sane/node_modules/is-extendable/README.md
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
# is-extendable [](http://badge.fury.io/js/is-extendable)
|
||||
|
||||
> Returns true if a value is any of the object types: array, regexp, plain object, function or date. This is useful for determining if a value can be extended, e.g. "can the value have keys?"
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i is-extendable --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isExtendable = require('is-extendable');
|
||||
```
|
||||
|
||||
Returns true if the value is any of the following:
|
||||
|
||||
* `array`
|
||||
* `regexp`
|
||||
* `plain object`
|
||||
* `function`
|
||||
* `date`
|
||||
* `error`
|
||||
|
||||
## Notes
|
||||
|
||||
All objects in JavaScript can have keys, but it's a pain to check for this, since we ether need to verify that the value is not `null` or `undefined` and:
|
||||
|
||||
* the value is not a primitive, or
|
||||
* that the object is an `object`, `function`
|
||||
|
||||
Also note that an `extendable` object is not the same as an [extensible object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible), which is one that (in es6) is not sealed, frozen, or marked as non-extensible using `preventExtensions`.
|
||||
|
||||
## Related projects
|
||||
|
||||
* [assign-deep](https://github.com/jonschlinkert/assign-deep): Deeply assign the enumerable properties of source objects to a destination object.
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [is-equal-shallow](https://github.com/jonschlinkert/is-equal-shallow): Does a shallow comparison of two objects, returning false if the keys or values differ.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ 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/is-extendable/issues/new)
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 04, 2015._
|
13
node_modules/sane/node_modules/is-extendable/index.js
generated
vendored
Normal file
13
node_modules/sane/node_modules/is-extendable/index.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*!
|
||||
* is-extendable <https://github.com/jonschlinkert/is-extendable>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function isExtendable(val) {
|
||||
return typeof val !== 'undefined' && val !== null
|
||||
&& (typeof val === 'object' || typeof val === 'function');
|
||||
};
|
51
node_modules/sane/node_modules/is-extendable/package.json
generated
vendored
Normal file
51
node_modules/sane/node_modules/is-extendable/package.json
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "is-extendable",
|
||||
"description": "Returns true if a value is any of the object types: array, regexp, plain object, function or date. This is useful for determining if a value can be extended, e.g. \"can the value have keys?\"",
|
||||
"version": "0.1.1",
|
||||
"homepage": "https://github.com/jonschlinkert/is-extendable",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/is-extendable",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-extendable/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"assign",
|
||||
"check",
|
||||
"date",
|
||||
"extend",
|
||||
"extensible",
|
||||
"function",
|
||||
"is",
|
||||
"object",
|
||||
"regex",
|
||||
"test"
|
||||
],
|
||||
"verbiage": {
|
||||
"related": {
|
||||
"list": [
|
||||
"isobject",
|
||||
"is-plain-object",
|
||||
"kind-of",
|
||||
"is-extendable",
|
||||
"is-equal-shallow",
|
||||
"extend-shallow",
|
||||
"assign-deep"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
21
node_modules/sane/node_modules/is-number/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/is-number/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-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.
|
115
node_modules/sane/node_modules/is-number/README.md
generated
vendored
Normal file
115
node_modules/sane/node_modules/is-number/README.md
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
# is-number [](https://www.npmjs.com/package/is-number) [](https://npmjs.org/package/is-number) [](https://travis-ci.org/jonschlinkert/is-number)
|
||||
|
||||
> Returns true if the value is a number. comprehensive tests.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save is-number
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To understand some of the rationale behind the decisions made in this library (and to learn about some oddities of number evaluation in JavaScript), [see this gist](https://gist.github.com/jonschlinkert/e30c70c713da325d0e81).
|
||||
|
||||
```js
|
||||
var isNumber = require('is-number');
|
||||
```
|
||||
|
||||
### true
|
||||
|
||||
See the [tests](./test.js) for more examples.
|
||||
|
||||
```js
|
||||
isNumber(5e3) //=> 'true'
|
||||
isNumber(0xff) //=> 'true'
|
||||
isNumber(-1.1) //=> 'true'
|
||||
isNumber(0) //=> 'true'
|
||||
isNumber(1) //=> 'true'
|
||||
isNumber(1.1) //=> 'true'
|
||||
isNumber(10) //=> 'true'
|
||||
isNumber(10.10) //=> 'true'
|
||||
isNumber(100) //=> 'true'
|
||||
isNumber('-1.1') //=> 'true'
|
||||
isNumber('0') //=> 'true'
|
||||
isNumber('012') //=> 'true'
|
||||
isNumber('0xff') //=> 'true'
|
||||
isNumber('1') //=> 'true'
|
||||
isNumber('1.1') //=> 'true'
|
||||
isNumber('10') //=> 'true'
|
||||
isNumber('10.10') //=> 'true'
|
||||
isNumber('100') //=> 'true'
|
||||
isNumber('5e3') //=> 'true'
|
||||
isNumber(parseInt('012')) //=> 'true'
|
||||
isNumber(parseFloat('012')) //=> 'true'
|
||||
```
|
||||
|
||||
### False
|
||||
|
||||
See the [tests](./test.js) for more examples.
|
||||
|
||||
```js
|
||||
isNumber('foo') //=> 'false'
|
||||
isNumber([1]) //=> 'false'
|
||||
isNumber([]) //=> 'false'
|
||||
isNumber(function () {}) //=> 'false'
|
||||
isNumber(Infinity) //=> 'false'
|
||||
isNumber(NaN) //=> 'false'
|
||||
isNumber(new Array('abc')) //=> 'false'
|
||||
isNumber(new Array(2)) //=> 'false'
|
||||
isNumber(new Buffer('abc')) //=> 'false'
|
||||
isNumber(null) //=> 'false'
|
||||
isNumber(undefined) //=> 'false'
|
||||
isNumber({abc: 'abc'}) //=> 'false'
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [even](https://www.npmjs.com/package/even): Get the even numbered items from an array. | [homepage](https://github.com/jonschlinkert/even "Get the even numbered items from an array.")
|
||||
* [is-even](https://www.npmjs.com/package/is-even): Return true if the given number is even. | [homepage](https://github.com/jonschlinkert/is-even "Return true if the given number is even.")
|
||||
* [is-odd](https://www.npmjs.com/package/is-odd): Returns true if the given number is odd. | [homepage](https://github.com/jonschlinkert/is-odd "Returns true if the given number is odd.")
|
||||
* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
|
||||
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||
* [odd](https://www.npmjs.com/package/odd): Get the odd numbered items from an array. | [homepage](https://github.com/jonschlinkert/odd "Get the odd numbered items from an array.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### 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/is-number/blob/master/LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on September 10, 2016._
|
22
node_modules/sane/node_modules/is-number/index.js
generated
vendored
Normal file
22
node_modules/sane/node_modules/is-number/index.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*!
|
||||
* is-number <https://github.com/jonschlinkert/is-number>
|
||||
*
|
||||
* Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var typeOf = require('kind-of');
|
||||
|
||||
module.exports = function isNumber(num) {
|
||||
var type = typeOf(num);
|
||||
|
||||
if (type === 'string') {
|
||||
if (!num.trim()) return false;
|
||||
} else if (type !== 'number') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (num - num + 1) >= 0;
|
||||
};
|
21
node_modules/sane/node_modules/is-number/node_modules/kind-of/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/is-number/node_modules/kind-of/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, 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.
|
261
node_modules/sane/node_modules/is-number/node_modules/kind-of/README.md
generated
vendored
Normal file
261
node_modules/sane/node_modules/is-number/node_modules/kind-of/README.md
generated
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
# kind-of [](https://www.npmjs.com/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://travis-ci.org/jonschlinkert/kind-of)
|
||||
|
||||
> Get the native type of a value.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save kind-of
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install kind-of --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> es5, browser and es6 ready
|
||||
|
||||
```js
|
||||
var kindOf = require('kind-of');
|
||||
|
||||
kindOf(undefined);
|
||||
//=> 'undefined'
|
||||
|
||||
kindOf(null);
|
||||
//=> 'null'
|
||||
|
||||
kindOf(true);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(false);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Boolean(true));
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Buffer(''));
|
||||
//=> 'buffer'
|
||||
|
||||
kindOf(42);
|
||||
//=> 'number'
|
||||
|
||||
kindOf(new Number(42));
|
||||
//=> 'number'
|
||||
|
||||
kindOf('str');
|
||||
//=> 'string'
|
||||
|
||||
kindOf(new String('str'));
|
||||
//=> 'string'
|
||||
|
||||
kindOf(arguments);
|
||||
//=> 'arguments'
|
||||
|
||||
kindOf({});
|
||||
//=> 'object'
|
||||
|
||||
kindOf(Object.create(null));
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Test());
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Date());
|
||||
//=> 'date'
|
||||
|
||||
kindOf([]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf([1, 2, 3]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf(new Array());
|
||||
//=> 'array'
|
||||
|
||||
kindOf(/foo/);
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(new RegExp('foo'));
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(function () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(function * () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Function());
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Map());
|
||||
//=> 'map'
|
||||
|
||||
kindOf(new WeakMap());
|
||||
//=> 'weakmap'
|
||||
|
||||
kindOf(new Set());
|
||||
//=> 'set'
|
||||
|
||||
kindOf(new WeakSet());
|
||||
//=> 'weakset'
|
||||
|
||||
kindOf(Symbol('str'));
|
||||
//=> 'symbol'
|
||||
|
||||
kindOf(new Int8Array());
|
||||
//=> 'int8array'
|
||||
|
||||
kindOf(new Uint8Array());
|
||||
//=> 'uint8array'
|
||||
|
||||
kindOf(new Uint8ClampedArray());
|
||||
//=> 'uint8clampedarray'
|
||||
|
||||
kindOf(new Int16Array());
|
||||
//=> 'int16array'
|
||||
|
||||
kindOf(new Uint16Array());
|
||||
//=> 'uint16array'
|
||||
|
||||
kindOf(new Int32Array());
|
||||
//=> 'int32array'
|
||||
|
||||
kindOf(new Uint32Array());
|
||||
//=> 'uint32array'
|
||||
|
||||
kindOf(new Float32Array());
|
||||
//=> 'float32array'
|
||||
|
||||
kindOf(new Float64Array());
|
||||
//=> 'float64array'
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
|
||||
Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
|
||||
|
||||
```bash
|
||||
#1: array
|
||||
current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
|
||||
lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
|
||||
lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
|
||||
|
||||
#2: boolean
|
||||
current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
|
||||
lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
|
||||
lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
|
||||
|
||||
#3: date
|
||||
current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
|
||||
lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
|
||||
lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
|
||||
|
||||
#4: function
|
||||
current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
|
||||
lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
|
||||
lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
|
||||
|
||||
#5: null
|
||||
current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
|
||||
lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
|
||||
lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
|
||||
|
||||
#6: number
|
||||
current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
|
||||
lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
|
||||
lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
|
||||
|
||||
#7: object
|
||||
current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
|
||||
lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
|
||||
lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
|
||||
|
||||
#8: regex
|
||||
current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
|
||||
lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
|
||||
lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
|
||||
|
||||
#9: string
|
||||
current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
|
||||
lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
|
||||
lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
|
||||
|
||||
#10: undef
|
||||
current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
|
||||
lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
|
||||
lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
|
||||
|
||||
```
|
||||
|
||||
## Optimizations
|
||||
|
||||
In 7 out of 8 cases, this library is 2x-10x faster than other top libraries included in the benchmarks. There are a few things that lead to this performance advantage, none of them hard and fast rules, but all of them simple and repeatable in almost any code library:
|
||||
|
||||
1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
|
||||
2. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type check would not be penalized it.
|
||||
3. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [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-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||
* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 59 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [miguelmota](https://github.com/miguelmota) |
|
||||
| 1 | [dtothefp](https://github.com/dtothefp) |
|
||||
| 1 | [ksheedlo](https://github.com/ksheedlo) |
|
||||
| 1 | [pdehaan](https://github.com/pdehaan) |
|
||||
| 1 | [laggingreflex](https://github.com/laggingreflex) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 16, 2017._
|
116
node_modules/sane/node_modules/is-number/node_modules/kind-of/index.js
generated
vendored
Normal file
116
node_modules/sane/node_modules/is-number/node_modules/kind-of/index.js
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
var isBuffer = require('is-buffer');
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Get the native `typeof` a value.
|
||||
*
|
||||
* @param {*} `val`
|
||||
* @return {*} Native javascript type
|
||||
*/
|
||||
|
||||
module.exports = function kindOf(val) {
|
||||
// primitivies
|
||||
if (typeof val === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (val === true || val === false || val instanceof Boolean) {
|
||||
return 'boolean';
|
||||
}
|
||||
if (typeof val === 'string' || val instanceof String) {
|
||||
return 'string';
|
||||
}
|
||||
if (typeof val === 'number' || val instanceof Number) {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
// functions
|
||||
if (typeof val === 'function' || val instanceof Function) {
|
||||
return 'function';
|
||||
}
|
||||
|
||||
// array
|
||||
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
// check for instances of RegExp and Date before calling `toString`
|
||||
if (val instanceof RegExp) {
|
||||
return 'regexp';
|
||||
}
|
||||
if (val instanceof Date) {
|
||||
return 'date';
|
||||
}
|
||||
|
||||
// other objects
|
||||
var type = toString.call(val);
|
||||
|
||||
if (type === '[object RegExp]') {
|
||||
return 'regexp';
|
||||
}
|
||||
if (type === '[object Date]') {
|
||||
return 'date';
|
||||
}
|
||||
if (type === '[object Arguments]') {
|
||||
return 'arguments';
|
||||
}
|
||||
if (type === '[object Error]') {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
// buffer
|
||||
if (isBuffer(val)) {
|
||||
return 'buffer';
|
||||
}
|
||||
|
||||
// es6: Map, WeakMap, Set, WeakSet
|
||||
if (type === '[object Set]') {
|
||||
return 'set';
|
||||
}
|
||||
if (type === '[object WeakSet]') {
|
||||
return 'weakset';
|
||||
}
|
||||
if (type === '[object Map]') {
|
||||
return 'map';
|
||||
}
|
||||
if (type === '[object WeakMap]') {
|
||||
return 'weakmap';
|
||||
}
|
||||
if (type === '[object Symbol]') {
|
||||
return 'symbol';
|
||||
}
|
||||
|
||||
// typed arrays
|
||||
if (type === '[object Int8Array]') {
|
||||
return 'int8array';
|
||||
}
|
||||
if (type === '[object Uint8Array]') {
|
||||
return 'uint8array';
|
||||
}
|
||||
if (type === '[object Uint8ClampedArray]') {
|
||||
return 'uint8clampedarray';
|
||||
}
|
||||
if (type === '[object Int16Array]') {
|
||||
return 'int16array';
|
||||
}
|
||||
if (type === '[object Uint16Array]') {
|
||||
return 'uint16array';
|
||||
}
|
||||
if (type === '[object Int32Array]') {
|
||||
return 'int32array';
|
||||
}
|
||||
if (type === '[object Uint32Array]') {
|
||||
return 'uint32array';
|
||||
}
|
||||
if (type === '[object Float32Array]') {
|
||||
return 'float32array';
|
||||
}
|
||||
if (type === '[object Float64Array]') {
|
||||
return 'float64array';
|
||||
}
|
||||
|
||||
// must be a plain object
|
||||
return 'object';
|
||||
};
|
90
node_modules/sane/node_modules/is-number/node_modules/kind-of/package.json
generated
vendored
Normal file
90
node_modules/sane/node_modules/is-number/node_modules/kind-of/package.json
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"name": "kind-of",
|
||||
"description": "Get the native type of a value.",
|
||||
"version": "3.2.2",
|
||||
"homepage": "https://github.com/jonschlinkert/kind-of",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"David Fox-Powell (https://dtothefp.github.io/me)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Ken Sheedlo (kensheedlo.com)",
|
||||
"laggingreflex (https://github.com/laggingreflex)",
|
||||
"Miguel Mota (https://miguelmota.com)",
|
||||
"Peter deHaan (http://about.me/peterdehaan)"
|
||||
],
|
||||
"repository": "jonschlinkert/kind-of",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/kind-of/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"prepublish": "browserify -o browser.js -e index.js -s index --bare"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-buffer": "^1.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"browserify": "^14.3.0",
|
||||
"glob": "^7.1.1",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"mocha": "^3.3.0",
|
||||
"type-of": "^2.0.1",
|
||||
"typeof": "^1.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"arguments",
|
||||
"array",
|
||||
"boolean",
|
||||
"check",
|
||||
"date",
|
||||
"function",
|
||||
"is",
|
||||
"is-type",
|
||||
"is-type-of",
|
||||
"kind",
|
||||
"kind-of",
|
||||
"number",
|
||||
"object",
|
||||
"of",
|
||||
"regexp",
|
||||
"string",
|
||||
"test",
|
||||
"type",
|
||||
"type-of",
|
||||
"typeof",
|
||||
"types"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-glob",
|
||||
"is-number",
|
||||
"is-primitive"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"verb"
|
||||
]
|
||||
}
|
||||
}
|
83
node_modules/sane/node_modules/is-number/package.json
generated
vendored
Normal file
83
node_modules/sane/node_modules/is-number/package.json
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"name": "is-number",
|
||||
"description": "Returns true if the value is a number. comprehensive tests.",
|
||||
"version": "3.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/is-number",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Charlike Mike Reagent (http://www.tunnckocore.tk)",
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "jonschlinkert/is-number",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-number/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"kind-of": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmarked": "^0.2.5",
|
||||
"chalk": "^1.1.3",
|
||||
"gulp-format-md": "^0.1.10",
|
||||
"mocha": "^3.0.2"
|
||||
},
|
||||
"keywords": [
|
||||
"check",
|
||||
"coerce",
|
||||
"coercion",
|
||||
"integer",
|
||||
"is",
|
||||
"is-nan",
|
||||
"is-num",
|
||||
"is-number",
|
||||
"istype",
|
||||
"kind",
|
||||
"math",
|
||||
"nan",
|
||||
"num",
|
||||
"number",
|
||||
"numeric",
|
||||
"test",
|
||||
"type",
|
||||
"typeof",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"even",
|
||||
"is-even",
|
||||
"is-odd",
|
||||
"is-primitive",
|
||||
"kind-of",
|
||||
"odd"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
]
|
||||
}
|
||||
}
|
21
node_modules/sane/node_modules/is-stream/index.js
generated
vendored
Normal file
21
node_modules/sane/node_modules/is-stream/index.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
var isStream = module.exports = function (stream) {
|
||||
return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
|
||||
};
|
||||
|
||||
isStream.writable = function (stream) {
|
||||
return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
|
||||
};
|
||||
|
||||
isStream.readable = function (stream) {
|
||||
return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
|
||||
};
|
||||
|
||||
isStream.duplex = function (stream) {
|
||||
return isStream.writable(stream) && isStream.readable(stream);
|
||||
};
|
||||
|
||||
isStream.transform = function (stream) {
|
||||
return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
|
||||
};
|
21
node_modules/sane/node_modules/is-stream/license
generated
vendored
Normal file
21
node_modules/sane/node_modules/is-stream/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
38
node_modules/sane/node_modules/is-stream/package.json
generated
vendored
Normal file
38
node_modules/sane/node_modules/is-stream/package.json
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "is-stream",
|
||||
"version": "1.1.0",
|
||||
"description": "Check if something is a Node.js stream",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-stream",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"stream",
|
||||
"type",
|
||||
"streams",
|
||||
"writable",
|
||||
"readable",
|
||||
"duplex",
|
||||
"transform",
|
||||
"check",
|
||||
"detect",
|
||||
"is"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"tempfile": "^1.1.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
42
node_modules/sane/node_modules/is-stream/readme.md
generated
vendored
Normal file
42
node_modules/sane/node_modules/is-stream/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
# is-stream [](https://travis-ci.org/sindresorhus/is-stream)
|
||||
|
||||
> Check if something is a [Node.js stream](https://nodejs.org/api/stream.html)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save is-stream
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const isStream = require('is-stream');
|
||||
|
||||
isStream(fs.createReadStream('unicorn.png'));
|
||||
//=> true
|
||||
|
||||
isStream({});
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### isStream(stream)
|
||||
|
||||
#### isStream.writable(stream)
|
||||
|
||||
#### isStream.readable(stream)
|
||||
|
||||
#### isStream.duplex(stream)
|
||||
|
||||
#### isStream.transform(stream)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
37
node_modules/sane/node_modules/micromatch/CHANGELOG.md
generated
vendored
Normal file
37
node_modules/sane/node_modules/micromatch/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
## History
|
||||
|
||||
### key
|
||||
|
||||
Changelog entries are classified using the following labels _(from [keep-a-changelog][]_):
|
||||
|
||||
- `added`: for new features
|
||||
- `changed`: for changes in existing functionality
|
||||
- `deprecated`: for once-stable features removed in upcoming releases
|
||||
- `removed`: for deprecated features removed in this release
|
||||
- `fixed`: for any bug fixes
|
||||
- `bumped`: updated dependencies, only minor or higher will be listed.
|
||||
|
||||
### [3.0.0] - 2017-04-11
|
||||
|
||||
TODO. There should be no breaking changes. Please report any regressions. I will [reformat these release notes](https://github.com/micromatch/micromatch/pull/76) and add them to the changelog as soon as I have a chance.
|
||||
|
||||
### [1.0.1] - 2016-12-12
|
||||
|
||||
**Added**
|
||||
|
||||
- Support for windows path edge cases where backslashes are used in brackets or other unusual combinations.
|
||||
|
||||
### [1.0.0] - 2016-12-12
|
||||
|
||||
Stable release.
|
||||
|
||||
### [0.1.0] - 2016-10-08
|
||||
|
||||
First release.
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...HEAD
|
||||
[0.2.0]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...0.2.0
|
||||
|
||||
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
|
||||
|
21
node_modules/sane/node_modules/micromatch/LICENSE
generated
vendored
Executable file
21
node_modules/sane/node_modules/micromatch/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2018, 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.
|
1150
node_modules/sane/node_modules/micromatch/README.md
generated
vendored
Normal file
1150
node_modules/sane/node_modules/micromatch/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
877
node_modules/sane/node_modules/micromatch/index.js
generated
vendored
Normal file
877
node_modules/sane/node_modules/micromatch/index.js
generated
vendored
Normal file
|
@ -0,0 +1,877 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var util = require('util');
|
||||
var braces = require('braces');
|
||||
var toRegex = require('to-regex');
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
/**
|
||||
* Local dependencies
|
||||
*/
|
||||
|
||||
var compilers = require('./lib/compilers');
|
||||
var parsers = require('./lib/parsers');
|
||||
var cache = require('./lib/cache');
|
||||
var utils = require('./lib/utils');
|
||||
var MAX_LENGTH = 1024 * 64;
|
||||
|
||||
/**
|
||||
* The main function takes a list of strings and one or more
|
||||
* glob patterns to use for matching.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
||||
* //=> [ 'a.js' ]
|
||||
* ```
|
||||
* @param {Array} `list` A list of strings to match
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Array} Returns an array of matches
|
||||
* @summary false
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function micromatch(list, patterns, options) {
|
||||
patterns = utils.arrayify(patterns);
|
||||
list = utils.arrayify(list);
|
||||
|
||||
var len = patterns.length;
|
||||
if (list.length === 0 || len === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (len === 1) {
|
||||
return micromatch.match(list, patterns[0], options);
|
||||
}
|
||||
|
||||
var omit = [];
|
||||
var keep = [];
|
||||
var idx = -1;
|
||||
|
||||
while (++idx < len) {
|
||||
var pattern = patterns[idx];
|
||||
|
||||
if (typeof pattern === 'string' && pattern.charCodeAt(0) === 33 /* ! */) {
|
||||
omit.push.apply(omit, micromatch.match(list, pattern.slice(1), options));
|
||||
} else {
|
||||
keep.push.apply(keep, micromatch.match(list, pattern, options));
|
||||
}
|
||||
}
|
||||
|
||||
var matches = utils.diff(keep, omit);
|
||||
if (!options || options.nodupes !== false) {
|
||||
return utils.unique(matches);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to the main function, but `pattern` must be a string.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.match(list, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'));
|
||||
* //=> ['a.a', 'a.aa']
|
||||
* ```
|
||||
* @param {Array} `list` Array of strings to match
|
||||
* @param {String} `pattern` Glob pattern to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Array} Returns an array of matches
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.match = function(list, pattern, options) {
|
||||
if (Array.isArray(pattern)) {
|
||||
throw new TypeError('expected pattern to be a string');
|
||||
}
|
||||
|
||||
var unixify = utils.unixify(options);
|
||||
var isMatch = memoize('match', pattern, options, micromatch.matcher);
|
||||
var matches = [];
|
||||
|
||||
list = utils.arrayify(list);
|
||||
var len = list.length;
|
||||
var idx = -1;
|
||||
|
||||
while (++idx < len) {
|
||||
var ele = list[idx];
|
||||
if (ele === pattern || isMatch(ele)) {
|
||||
matches.push(utils.value(ele, unixify, options));
|
||||
}
|
||||
}
|
||||
|
||||
// if no options were passed, uniquify results and return
|
||||
if (typeof options === 'undefined') {
|
||||
return utils.unique(matches);
|
||||
}
|
||||
|
||||
if (matches.length === 0) {
|
||||
if (options.failglob === true) {
|
||||
throw new Error('no matches found for "' + pattern + '"');
|
||||
}
|
||||
if (options.nonull === true || options.nullglob === true) {
|
||||
return [options.unescape ? utils.unescape(pattern) : pattern];
|
||||
}
|
||||
}
|
||||
|
||||
// if `opts.ignore` was defined, diff ignored list
|
||||
if (options.ignore) {
|
||||
matches = micromatch.not(matches, options.ignore, options);
|
||||
}
|
||||
|
||||
return options.nodupes !== false ? utils.unique(matches) : matches;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the specified `string` matches the given glob `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.isMatch(string, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.isMatch('a.a', '*.a'));
|
||||
* //=> true
|
||||
* console.log(mm.isMatch('a.b', '*.a'));
|
||||
* //=> false
|
||||
* ```
|
||||
* @param {String} `string` String to match
|
||||
* @param {String} `pattern` Glob pattern to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if the string matches the glob pattern.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.isMatch = function(str, pattern, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
|
||||
}
|
||||
|
||||
if (isEmptyString(str) || isEmptyString(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var equals = utils.equalsPattern(options);
|
||||
if (equals(str)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var isMatch = memoize('isMatch', pattern, options, micromatch.matcher);
|
||||
return isMatch(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if some of the strings in the given `list` match any of the
|
||||
* given glob `patterns`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.some(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
||||
* // true
|
||||
* console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* ```
|
||||
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if any patterns match `str`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.some = function(list, patterns, options) {
|
||||
if (typeof list === 'string') {
|
||||
list = [list];
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (micromatch(list[i], patterns, options).length === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if every string in the given `list` matches
|
||||
* any of the given glob `patterns`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.every(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.every('foo.js', ['foo.js']));
|
||||
* // true
|
||||
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
|
||||
* // true
|
||||
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* ```
|
||||
* @param {String|Array} `list` The string or array of strings to test.
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if any patterns match `str`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.every = function(list, patterns, options) {
|
||||
if (typeof list === 'string') {
|
||||
list = [list];
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (micromatch(list[i], patterns, options).length !== 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if **any** of the given glob `patterns`
|
||||
* match the specified `string`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.any(string, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.any('a.a', ['b.*', '*.a']));
|
||||
* //=> true
|
||||
* console.log(mm.any('a.a', 'b.*'));
|
||||
* //=> false
|
||||
* ```
|
||||
* @param {String|Array} `str` The string to test.
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if any patterns match `str`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.any = function(str, patterns, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
|
||||
}
|
||||
|
||||
if (isEmptyString(str) || isEmptyString(patterns)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof patterns === 'string') {
|
||||
patterns = [patterns];
|
||||
}
|
||||
|
||||
for (var i = 0; i < patterns.length; i++) {
|
||||
if (micromatch.isMatch(str, patterns[i], options)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if **all** of the given `patterns` match
|
||||
* the specified string.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.all(string, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['foo.js']));
|
||||
* // true
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', '!foo.js']));
|
||||
* // false
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', 'foo.js']));
|
||||
* // true
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
||||
* // true
|
||||
* ```
|
||||
* @param {String|Array} `str` The string to test.
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if any patterns match `str`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.all = function(str, patterns, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
|
||||
}
|
||||
if (typeof patterns === 'string') {
|
||||
patterns = [patterns];
|
||||
}
|
||||
for (var i = 0; i < patterns.length; i++) {
|
||||
if (!micromatch.isMatch(str, patterns[i], options)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.not(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
||||
* //=> ['b.b', 'c.c']
|
||||
* ```
|
||||
* @param {Array} `list` Array of strings to match.
|
||||
* @param {String|Array} `patterns` One or more glob pattern to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Array} Returns an array of strings that **do not match** the given patterns.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.not = function(list, patterns, options) {
|
||||
var opts = extend({}, options);
|
||||
var ignore = opts.ignore;
|
||||
delete opts.ignore;
|
||||
|
||||
var unixify = utils.unixify(opts);
|
||||
list = utils.arrayify(list).map(unixify);
|
||||
|
||||
var matches = utils.diff(list, micromatch(list, patterns, opts));
|
||||
if (ignore) {
|
||||
matches = utils.diff(matches, micromatch(list, ignore));
|
||||
}
|
||||
|
||||
return opts.nodupes !== false ? utils.unique(matches) : matches;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given `string` contains the given pattern. Similar
|
||||
* to [.isMatch](#isMatch) but the pattern can match any part of the string.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.contains(string, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.contains('aa/bb/cc', '*b'));
|
||||
* //=> true
|
||||
* console.log(mm.contains('aa/bb/cc', '*d'));
|
||||
* //=> false
|
||||
* ```
|
||||
* @param {String} `str` The string to match.
|
||||
* @param {String|Array} `patterns` Glob pattern to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns true if the patter matches any part of `str`.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.contains = function(str, patterns, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
|
||||
}
|
||||
|
||||
if (typeof patterns === 'string') {
|
||||
if (isEmptyString(str) || isEmptyString(patterns)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var equals = utils.equalsPattern(patterns, options);
|
||||
if (equals(str)) {
|
||||
return true;
|
||||
}
|
||||
var contains = utils.containsPattern(patterns, options);
|
||||
if (contains(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var opts = extend({}, options, {contains: true});
|
||||
return micromatch.any(str, patterns, opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given pattern and options should enable
|
||||
* the `matchBase` option.
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
micromatch.matchBase = function(pattern, options) {
|
||||
if (pattern && pattern.indexOf('/') !== -1 || !options) return false;
|
||||
return options.basename === true || options.matchBase === true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter the keys of the given object with the given `glob` pattern
|
||||
* and `options`. Does not attempt to match nested keys. If you need this feature,
|
||||
* use [glob-object][] instead.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.matchKeys(object, patterns[, options]);
|
||||
*
|
||||
* var obj = { aa: 'a', ab: 'b', ac: 'c' };
|
||||
* console.log(mm.matchKeys(obj, '*b'));
|
||||
* //=> { ab: 'b' }
|
||||
* ```
|
||||
* @param {Object} `object` The object with keys to filter.
|
||||
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Object} Returns an object with only keys that match the given patterns.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.matchKeys = function(obj, patterns, options) {
|
||||
if (!utils.isObject(obj)) {
|
||||
throw new TypeError('expected the first argument to be an object');
|
||||
}
|
||||
var keys = micromatch(Object.keys(obj), patterns, options);
|
||||
return utils.pick(obj, keys);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a memoized matcher function from the given glob `pattern` and `options`.
|
||||
* The returned function takes a string to match as its only argument and returns
|
||||
* true if the string is a match.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.matcher(pattern[, options]);
|
||||
*
|
||||
* var isMatch = mm.matcher('*.!(*a)');
|
||||
* console.log(isMatch('a.a'));
|
||||
* //=> false
|
||||
* console.log(isMatch('a.b'));
|
||||
* //=> true
|
||||
* ```
|
||||
* @param {String} `pattern` Glob pattern
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed.
|
||||
* @return {Function} Returns a matcher function.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.matcher = function matcher(pattern, options) {
|
||||
if (Array.isArray(pattern)) {
|
||||
return compose(pattern, options, matcher);
|
||||
}
|
||||
|
||||
// if pattern is a regex
|
||||
if (pattern instanceof RegExp) {
|
||||
return test(pattern);
|
||||
}
|
||||
|
||||
// if pattern is invalid
|
||||
if (!utils.isString(pattern)) {
|
||||
throw new TypeError('expected pattern to be an array, string or regex');
|
||||
}
|
||||
|
||||
// if pattern is a non-glob string
|
||||
if (!utils.hasSpecialChars(pattern)) {
|
||||
if (options && options.nocase === true) {
|
||||
pattern = pattern.toLowerCase();
|
||||
}
|
||||
return utils.matchPath(pattern, options);
|
||||
}
|
||||
|
||||
// if pattern is a glob string
|
||||
var re = micromatch.makeRe(pattern, options);
|
||||
|
||||
// if `options.matchBase` or `options.basename` is defined
|
||||
if (micromatch.matchBase(pattern, options)) {
|
||||
return utils.matchBasename(re, options);
|
||||
}
|
||||
|
||||
function test(regex) {
|
||||
var equals = utils.equalsPattern(options);
|
||||
var unixify = utils.unixify(options);
|
||||
|
||||
return function(str) {
|
||||
if (equals(str)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (regex.test(unixify(str))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
var fn = test(re);
|
||||
Object.defineProperty(fn, 'result', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: re.result
|
||||
});
|
||||
return fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.capture(pattern, string[, options]);
|
||||
*
|
||||
* console.log(mm.capture('test/*.js', 'test/foo.js'));
|
||||
* //=> ['foo']
|
||||
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
||||
* //=> null
|
||||
* ```
|
||||
* @param {String} `pattern` Glob pattern to use for matching.
|
||||
* @param {String} `string` String to match
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
||||
* @return {Boolean} Returns an array of captures if the string matches the glob pattern, otherwise `null`.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.capture = function(pattern, str, options) {
|
||||
var re = micromatch.makeRe(pattern, extend({capture: true}, options));
|
||||
var unixify = utils.unixify(options);
|
||||
|
||||
function match() {
|
||||
return function(string) {
|
||||
var match = re.exec(unixify(string));
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return match.slice(1);
|
||||
};
|
||||
}
|
||||
|
||||
var capture = memoize('capture', pattern, options, match);
|
||||
return capture(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a regular expression from the given glob `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.makeRe(pattern[, options]);
|
||||
*
|
||||
* console.log(mm.makeRe('*.js'));
|
||||
* //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
||||
* ```
|
||||
* @param {String} `pattern` A glob pattern to convert to regex.
|
||||
* @param {Object} `options` See available [options](#options) for changing how matches are performed.
|
||||
* @return {RegExp} Returns a regex created from the given pattern.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.makeRe = function(pattern, options) {
|
||||
if (typeof pattern !== 'string') {
|
||||
throw new TypeError('expected pattern to be a string');
|
||||
}
|
||||
|
||||
if (pattern.length > MAX_LENGTH) {
|
||||
throw new Error('expected pattern to be less than ' + MAX_LENGTH + ' characters');
|
||||
}
|
||||
|
||||
function makeRe() {
|
||||
var result = micromatch.create(pattern, options);
|
||||
var ast_array = [];
|
||||
var output = result.map(function(obj) {
|
||||
obj.ast.state = obj.state;
|
||||
ast_array.push(obj.ast);
|
||||
return obj.output;
|
||||
});
|
||||
|
||||
var regex = toRegex(output.join('|'), options);
|
||||
Object.defineProperty(regex, 'result', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: ast_array
|
||||
});
|
||||
return regex;
|
||||
}
|
||||
|
||||
return memoize('makeRe', pattern, options, makeRe);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expand the given brace `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* console.log(mm.braces('foo/{a,b}/bar'));
|
||||
* //=> ['foo/(a|b)/bar']
|
||||
*
|
||||
* console.log(mm.braces('foo/{a,b}/bar', {expand: true}));
|
||||
* //=> ['foo/(a|b)/bar']
|
||||
* ```
|
||||
* @param {String} `pattern` String with brace pattern to expand.
|
||||
* @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.braces = function(pattern, options) {
|
||||
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
|
||||
throw new TypeError('expected pattern to be an array or string');
|
||||
}
|
||||
|
||||
function expand() {
|
||||
if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
|
||||
return utils.arrayify(pattern);
|
||||
}
|
||||
return braces(pattern, options);
|
||||
}
|
||||
|
||||
return memoize('braces', pattern, options, expand);
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy to the [micromatch.braces](#method), for parity with
|
||||
* minimatch.
|
||||
*/
|
||||
|
||||
micromatch.braceExpand = function(pattern, options) {
|
||||
var opts = extend({}, options, {expand: true});
|
||||
return micromatch.braces(pattern, opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the given glob `pattern` and returns an array of abstract syntax
|
||||
* trees (ASTs), with the compiled `output` and optional source `map` on
|
||||
* each AST.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.create(pattern[, options]);
|
||||
*
|
||||
* console.log(mm.create('abc/*.js'));
|
||||
* // [{ options: { source: 'string', sourcemap: true },
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { ... },
|
||||
* // output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js',
|
||||
* // ast:
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // nodes:
|
||||
* // [ ... ],
|
||||
* // dot: false,
|
||||
* // input: 'abc/*.js' },
|
||||
* // parsingErrors: [],
|
||||
* // map:
|
||||
* // { version: 3,
|
||||
* // sources: [ 'string' ],
|
||||
* // names: [],
|
||||
* // mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE',
|
||||
* // sourcesContent: [ 'abc/*.js' ] },
|
||||
* // position: { line: 1, column: 28 },
|
||||
* // content: {},
|
||||
* // files: {},
|
||||
* // idx: 6 }]
|
||||
* ```
|
||||
* @param {String} `pattern` Glob pattern to parse and compile.
|
||||
* @param {Object} `options` Any [options](#options) to change how parsing and compiling is performed.
|
||||
* @return {Object} Returns an object with the parsed AST, compiled string and optional source map.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.create = function(pattern, options) {
|
||||
return memoize('create', pattern, options, function() {
|
||||
function create(str, opts) {
|
||||
return micromatch.compile(micromatch.parse(str, opts), opts);
|
||||
}
|
||||
|
||||
pattern = micromatch.braces(pattern, options);
|
||||
var len = pattern.length;
|
||||
var idx = -1;
|
||||
var res = [];
|
||||
|
||||
while (++idx < len) {
|
||||
res.push(create(pattern[idx], options));
|
||||
}
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.parse(pattern[, options]);
|
||||
*
|
||||
* var ast = mm.parse('a/{b,c}/d');
|
||||
* console.log(ast);
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // input: 'a/{b,c}/d',
|
||||
* // nodes:
|
||||
* // [ { type: 'bos', val: '' },
|
||||
* // { type: 'text', val: 'a/' },
|
||||
* // { type: 'brace',
|
||||
* // nodes:
|
||||
* // [ { type: 'brace.open', val: '{' },
|
||||
* // { type: 'text', val: 'b,c' },
|
||||
* // { type: 'brace.close', val: '}' } ] },
|
||||
* // { type: 'text', val: '/d' },
|
||||
* // { type: 'eos', val: '' } ] }
|
||||
* ```
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an AST
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.parse = function(pattern, options) {
|
||||
if (typeof pattern !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
|
||||
function parse() {
|
||||
var snapdragon = utils.instantiate(null, options);
|
||||
parsers(snapdragon, options);
|
||||
|
||||
var ast = snapdragon.parse(pattern, options);
|
||||
utils.define(ast, 'snapdragon', snapdragon);
|
||||
ast.input = pattern;
|
||||
return ast;
|
||||
}
|
||||
|
||||
return memoize('parse', pattern, options, parse);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile the given `ast` or string with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.compile(ast[, options]);
|
||||
*
|
||||
* var ast = mm.parse('a/{b,c}/d');
|
||||
* console.log(mm.compile(ast));
|
||||
* // { options: { source: 'string' },
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { eos: [Function],
|
||||
* // noop: [Function],
|
||||
* // bos: [Function],
|
||||
* // brace: [Function],
|
||||
* // 'brace.open': [Function],
|
||||
* // text: [Function],
|
||||
* // 'brace.close': [Function] },
|
||||
* // output: [ 'a/(b|c)/d' ],
|
||||
* // ast:
|
||||
* // { ... },
|
||||
* // parsingErrors: [] }
|
||||
* ```
|
||||
* @param {Object|String} `ast`
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an object that has an `output` property with the compiled string.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.compile = function(ast, options) {
|
||||
if (typeof ast === 'string') {
|
||||
ast = micromatch.parse(ast, options);
|
||||
}
|
||||
|
||||
return memoize('compile', ast.input, options, function() {
|
||||
var snapdragon = utils.instantiate(ast, options);
|
||||
compilers(snapdragon, options);
|
||||
return snapdragon.compile(ast, options);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the regex cache.
|
||||
*
|
||||
* ```js
|
||||
* mm.clearCache();
|
||||
* ```
|
||||
* @api public
|
||||
*/
|
||||
|
||||
micromatch.clearCache = function() {
|
||||
micromatch.cache.caches = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given value is effectively an empty string
|
||||
*/
|
||||
|
||||
function isEmptyString(val) {
|
||||
return String(val) === '' || String(val) === './';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compose a matcher function with the given patterns.
|
||||
* This allows matcher functions to be compiled once and
|
||||
* called multiple times.
|
||||
*/
|
||||
|
||||
function compose(patterns, options, matcher) {
|
||||
var matchers;
|
||||
|
||||
return memoize('compose', String(patterns), options, function() {
|
||||
return function(file) {
|
||||
// delay composition until it's invoked the first time,
|
||||
// after that it won't be called again
|
||||
if (!matchers) {
|
||||
matchers = [];
|
||||
for (var i = 0; i < patterns.length; i++) {
|
||||
matchers.push(matcher(patterns[i], options));
|
||||
}
|
||||
}
|
||||
|
||||
var len = matchers.length;
|
||||
while (len--) {
|
||||
if (matchers[len](file) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Memoize a generated regex or function. A unique key is generated
|
||||
* from the `type` (usually method name), the `pattern`, and
|
||||
* user-defined options.
|
||||
*/
|
||||
|
||||
function memoize(type, pattern, options, fn) {
|
||||
var key = utils.createKey(type + '=' + pattern, options);
|
||||
|
||||
if (options && options.cache === false) {
|
||||
return fn(pattern, options);
|
||||
}
|
||||
|
||||
if (cache.has(type, key)) {
|
||||
return cache.get(type, key);
|
||||
}
|
||||
|
||||
var val = fn(pattern, options);
|
||||
cache.set(type, key, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose compiler, parser and cache on `micromatch`
|
||||
*/
|
||||
|
||||
micromatch.compilers = compilers;
|
||||
micromatch.parsers = parsers;
|
||||
micromatch.caches = cache.caches;
|
||||
|
||||
/**
|
||||
* Expose `micromatch`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = micromatch;
|
BIN
node_modules/sane/node_modules/micromatch/lib/.DS_Store
generated
vendored
Normal file
BIN
node_modules/sane/node_modules/micromatch/lib/.DS_Store
generated
vendored
Normal file
Binary file not shown.
1
node_modules/sane/node_modules/micromatch/lib/cache.js
generated
vendored
Normal file
1
node_modules/sane/node_modules/micromatch/lib/cache.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = new (require('fragment-cache'))();
|
77
node_modules/sane/node_modules/micromatch/lib/compilers.js
generated
vendored
Normal file
77
node_modules/sane/node_modules/micromatch/lib/compilers.js
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
|
||||
var nanomatch = require('nanomatch');
|
||||
var extglob = require('extglob');
|
||||
|
||||
module.exports = function(snapdragon) {
|
||||
var compilers = snapdragon.compiler.compilers;
|
||||
var opts = snapdragon.options;
|
||||
|
||||
// register nanomatch compilers
|
||||
snapdragon.use(nanomatch.compilers);
|
||||
|
||||
// get references to some specific nanomatch compilers before they
|
||||
// are overridden by the extglob and/or custom compilers
|
||||
var escape = compilers.escape;
|
||||
var qmark = compilers.qmark;
|
||||
var slash = compilers.slash;
|
||||
var star = compilers.star;
|
||||
var text = compilers.text;
|
||||
var plus = compilers.plus;
|
||||
var dot = compilers.dot;
|
||||
|
||||
// register extglob compilers or escape exglobs if disabled
|
||||
if (opts.extglob === false || opts.noext === true) {
|
||||
snapdragon.compiler.use(escapeExtglobs);
|
||||
} else {
|
||||
snapdragon.use(extglob.compilers);
|
||||
}
|
||||
|
||||
snapdragon.use(function() {
|
||||
this.options.star = this.options.star || function(/*node*/) {
|
||||
return '[^\\\\/]*?';
|
||||
};
|
||||
});
|
||||
|
||||
// custom micromatch compilers
|
||||
snapdragon.compiler
|
||||
|
||||
// reset referenced compiler
|
||||
.set('dot', dot)
|
||||
.set('escape', escape)
|
||||
.set('plus', plus)
|
||||
.set('slash', slash)
|
||||
.set('qmark', qmark)
|
||||
.set('star', star)
|
||||
.set('text', text);
|
||||
};
|
||||
|
||||
function escapeExtglobs(compiler) {
|
||||
compiler.set('paren', function(node) {
|
||||
var val = '';
|
||||
visit(node, function(tok) {
|
||||
if (tok.val) val += (/^\W/.test(tok.val) ? '\\' : '') + tok.val;
|
||||
});
|
||||
return this.emit(val, node);
|
||||
});
|
||||
|
||||
/**
|
||||
* Visit `node` with the given `fn`
|
||||
*/
|
||||
|
||||
function visit(node, fn) {
|
||||
return node.nodes ? mapVisit(node.nodes, fn) : fn(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map visit over array of `nodes`.
|
||||
*/
|
||||
|
||||
function mapVisit(nodes, fn) {
|
||||
var len = nodes.length;
|
||||
var idx = -1;
|
||||
while (++idx < len) {
|
||||
visit(nodes[idx], fn);
|
||||
}
|
||||
}
|
||||
}
|
83
node_modules/sane/node_modules/micromatch/lib/parsers.js
generated
vendored
Normal file
83
node_modules/sane/node_modules/micromatch/lib/parsers.js
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
'use strict';
|
||||
|
||||
var extglob = require('extglob');
|
||||
var nanomatch = require('nanomatch');
|
||||
var regexNot = require('regex-not');
|
||||
var toRegex = require('to-regex');
|
||||
var not;
|
||||
|
||||
/**
|
||||
* Characters to use in negation regex (we want to "not" match
|
||||
* characters that are matched by other parsers)
|
||||
*/
|
||||
|
||||
var TEXT = '([!@*?+]?\\(|\\)|\\[:?(?=.*?:?\\])|:?\\]|[*+?!^$.\\\\/])+';
|
||||
var createNotRegex = function(opts) {
|
||||
return not || (not = textRegex(TEXT));
|
||||
};
|
||||
|
||||
/**
|
||||
* Parsers
|
||||
*/
|
||||
|
||||
module.exports = function(snapdragon) {
|
||||
var parsers = snapdragon.parser.parsers;
|
||||
|
||||
// register nanomatch parsers
|
||||
snapdragon.use(nanomatch.parsers);
|
||||
|
||||
// get references to some specific nanomatch parsers before they
|
||||
// are overridden by the extglob and/or parsers
|
||||
var escape = parsers.escape;
|
||||
var slash = parsers.slash;
|
||||
var qmark = parsers.qmark;
|
||||
var plus = parsers.plus;
|
||||
var star = parsers.star;
|
||||
var dot = parsers.dot;
|
||||
|
||||
// register extglob parsers
|
||||
snapdragon.use(extglob.parsers);
|
||||
|
||||
// custom micromatch parsers
|
||||
snapdragon.parser
|
||||
.use(function() {
|
||||
// override "notRegex" created in nanomatch parser
|
||||
this.notRegex = /^\!+(?!\()/;
|
||||
})
|
||||
// reset the referenced parsers
|
||||
.capture('escape', escape)
|
||||
.capture('slash', slash)
|
||||
.capture('qmark', qmark)
|
||||
.capture('star', star)
|
||||
.capture('plus', plus)
|
||||
.capture('dot', dot)
|
||||
|
||||
/**
|
||||
* Override `text` parser
|
||||
*/
|
||||
|
||||
.capture('text', function() {
|
||||
if (this.isInside('bracket')) return;
|
||||
var pos = this.position();
|
||||
var m = this.match(createNotRegex(this.options));
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
// escape regex boundary characters and simple brackets
|
||||
var val = m[0].replace(/([[\]^$])/g, '\\$1');
|
||||
|
||||
return pos({
|
||||
type: 'text',
|
||||
val: val
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create text regex
|
||||
*/
|
||||
|
||||
function textRegex(pattern) {
|
||||
var notStr = regexNot.create(pattern, {contains: true, strictClose: false});
|
||||
var prefix = '(?:[\\^]|\\\\|';
|
||||
return toRegex(prefix + notStr + ')', {strictClose: false});
|
||||
}
|
309
node_modules/sane/node_modules/micromatch/lib/utils.js
generated
vendored
Normal file
309
node_modules/sane/node_modules/micromatch/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,309 @@
|
|||
'use strict';
|
||||
|
||||
var utils = module.exports;
|
||||
var path = require('path');
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var Snapdragon = require('snapdragon');
|
||||
utils.define = require('define-property');
|
||||
utils.diff = require('arr-diff');
|
||||
utils.extend = require('extend-shallow');
|
||||
utils.pick = require('object.pick');
|
||||
utils.typeOf = require('kind-of');
|
||||
utils.unique = require('array-unique');
|
||||
|
||||
/**
|
||||
* Returns true if the platform is windows, or `path.sep` is `\\`.
|
||||
* This is defined as a function to allow `path.sep` to be set in unit tests,
|
||||
* or by the user, if there is a reason to do so.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
utils.isWindows = function() {
|
||||
return path.sep === '\\' || process.platform === 'win32';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the `Snapdragon` instance to use
|
||||
*/
|
||||
|
||||
utils.instantiate = function(ast, options) {
|
||||
var snapdragon;
|
||||
// if an instance was created by `.parse`, use that instance
|
||||
if (utils.typeOf(ast) === 'object' && ast.snapdragon) {
|
||||
snapdragon = ast.snapdragon;
|
||||
// if the user supplies an instance on options, use that instance
|
||||
} else if (utils.typeOf(options) === 'object' && options.snapdragon) {
|
||||
snapdragon = options.snapdragon;
|
||||
// create a new instance
|
||||
} else {
|
||||
snapdragon = new Snapdragon(options);
|
||||
}
|
||||
|
||||
utils.define(snapdragon, 'parse', function(str, options) {
|
||||
var parsed = Snapdragon.prototype.parse.apply(this, arguments);
|
||||
parsed.input = str;
|
||||
|
||||
// escape unmatched brace/bracket/parens
|
||||
var last = this.parser.stack.pop();
|
||||
if (last && this.options.strictErrors !== true) {
|
||||
var open = last.nodes[0];
|
||||
var inner = last.nodes[1];
|
||||
if (last.type === 'bracket') {
|
||||
if (inner.val.charAt(0) === '[') {
|
||||
inner.val = '\\' + inner.val;
|
||||
}
|
||||
|
||||
} else {
|
||||
open.val = '\\' + open.val;
|
||||
var sibling = open.parent.nodes[1];
|
||||
if (sibling.type === 'star') {
|
||||
sibling.loose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add non-enumerable parser reference
|
||||
utils.define(parsed, 'parser', this.parser);
|
||||
return parsed;
|
||||
});
|
||||
|
||||
return snapdragon;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the key to use for memoization. The key is generated
|
||||
* by iterating over the options and concatenating key-value pairs
|
||||
* to the pattern string.
|
||||
*/
|
||||
|
||||
utils.createKey = function(pattern, options) {
|
||||
if (utils.typeOf(options) !== 'object') {
|
||||
return pattern;
|
||||
}
|
||||
var val = pattern;
|
||||
var keys = Object.keys(options);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
val += ';' + key + '=' + String(options[key]);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cast `val` to an array
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
utils.arrayify = function(val) {
|
||||
if (typeof val === 'string') return [val];
|
||||
return val ? (Array.isArray(val) ? val : [val]) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true if `val` is a non-empty string
|
||||
*/
|
||||
|
||||
utils.isString = function(val) {
|
||||
return typeof val === 'string';
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true if `val` is a non-empty string
|
||||
*/
|
||||
|
||||
utils.isObject = function(val) {
|
||||
return utils.typeOf(val) === 'object';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given `str` has special characters
|
||||
*/
|
||||
|
||||
utils.hasSpecialChars = function(str) {
|
||||
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape regex characters in the given string
|
||||
*/
|
||||
|
||||
utils.escapeRegex = function(str) {
|
||||
return str.replace(/[-[\]{}()^$|*+?.\\\/\s]/g, '\\$&');
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize slashes in the given filepath.
|
||||
*
|
||||
* @param {String} `filepath`
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
utils.toPosixPath = function(str) {
|
||||
return str.replace(/\\+/g, '/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip backslashes before special characters in a string.
|
||||
*
|
||||
* @param {String} `str`
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
utils.unescape = function(str) {
|
||||
return utils.toPosixPath(str.replace(/\\(?=[*+?!.])/g, ''));
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip the prefix from a filepath
|
||||
* @param {String} `fp`
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
utils.stripPrefix = function(str) {
|
||||
if (str.charAt(0) !== '.') {
|
||||
return str;
|
||||
}
|
||||
var ch = str.charAt(1);
|
||||
if (utils.isSlash(ch)) {
|
||||
return str.slice(2);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given str is an escaped or
|
||||
* unescaped path character
|
||||
*/
|
||||
|
||||
utils.isSlash = function(str) {
|
||||
return str === '/' || str === '\\/' || str === '\\' || str === '\\\\';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that returns true if the given
|
||||
* pattern matches or contains a `filepath`
|
||||
*
|
||||
* @param {String} `pattern`
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
utils.matchPath = function(pattern, options) {
|
||||
return (options && options.contains)
|
||||
? utils.containsPattern(pattern, options)
|
||||
: utils.equalsPattern(pattern, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given (original) filepath or unixified path are equal
|
||||
* to the given pattern.
|
||||
*/
|
||||
|
||||
utils._equals = function(filepath, unixPath, pattern) {
|
||||
return pattern === filepath || pattern === unixPath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given (original) filepath or unixified path contain
|
||||
* the given pattern.
|
||||
*/
|
||||
|
||||
utils._contains = function(filepath, unixPath, pattern) {
|
||||
return filepath.indexOf(pattern) !== -1 || unixPath.indexOf(pattern) !== -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that returns true if the given
|
||||
* pattern is the same as a given `filepath`
|
||||
*
|
||||
* @param {String} `pattern`
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
utils.equalsPattern = function(pattern, options) {
|
||||
var unixify = utils.unixify(options);
|
||||
options = options || {};
|
||||
|
||||
return function fn(filepath) {
|
||||
var equal = utils._equals(filepath, unixify(filepath), pattern);
|
||||
if (equal === true || options.nocase !== true) {
|
||||
return equal;
|
||||
}
|
||||
var lower = filepath.toLowerCase();
|
||||
return utils._equals(lower, unixify(lower), pattern);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that returns true if the given
|
||||
* pattern contains a `filepath`
|
||||
*
|
||||
* @param {String} `pattern`
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
utils.containsPattern = function(pattern, options) {
|
||||
var unixify = utils.unixify(options);
|
||||
options = options || {};
|
||||
|
||||
return function(filepath) {
|
||||
var contains = utils._contains(filepath, unixify(filepath), pattern);
|
||||
if (contains === true || options.nocase !== true) {
|
||||
return contains;
|
||||
}
|
||||
var lower = filepath.toLowerCase();
|
||||
return utils._contains(lower, unixify(lower), pattern);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that returns true if the given
|
||||
* regex matches the `filename` of a file path.
|
||||
*
|
||||
* @param {RegExp} `re` Matching regex
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
utils.matchBasename = function(re) {
|
||||
return function(filepath) {
|
||||
return re.test(path.basename(filepath));
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines the filepath to return based on the provided options.
|
||||
* @return {any}
|
||||
*/
|
||||
|
||||
utils.value = function(str, unixify, options) {
|
||||
if (options && options.unixify === false) {
|
||||
return str;
|
||||
}
|
||||
return unixify(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that normalizes slashes in a string to forward
|
||||
* slashes, strips `./` from beginning of paths, and optionally unescapes
|
||||
* special characters.
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
utils.unixify = function(options) {
|
||||
options = options || {};
|
||||
return function(filepath) {
|
||||
if (utils.isWindows() || options.unixify === true) {
|
||||
filepath = utils.toPosixPath(filepath);
|
||||
}
|
||||
if (options.stripPrefix !== false) {
|
||||
filepath = utils.stripPrefix(filepath);
|
||||
}
|
||||
if (options.unescape === true) {
|
||||
filepath = utils.unescape(filepath);
|
||||
}
|
||||
return filepath;
|
||||
};
|
||||
};
|
147
node_modules/sane/node_modules/micromatch/package.json
generated
vendored
Normal file
147
node_modules/sane/node_modules/micromatch/package.json
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
{
|
||||
"name": "micromatch",
|
||||
"description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.",
|
||||
"version": "3.1.10",
|
||||
"homepage": "https://github.com/micromatch/micromatch",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Amila Welihinda (amilajack.com)",
|
||||
"Bogdan Chadkin (https://github.com/TrySound)",
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"Devon Govett (http://badassjs.com)",
|
||||
"Elan Shanker (https://github.com/es128)",
|
||||
"Fabrício Matté (https://ultcombo.js.org)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Martin Kolárik (https://kolarik.sk)",
|
||||
"Olsten Larck (https://i.am.charlike.online)",
|
||||
"Paul Miller (paulmillr.com)",
|
||||
"Tom Byrer (https://github.com/tomByrer)",
|
||||
"Tyler Akins (http://rumkin.com)",
|
||||
"(https://github.com/DianeLooney)"
|
||||
],
|
||||
"repository": "micromatch/micromatch",
|
||||
"bugs": {
|
||||
"url": "https://github.com/micromatch/micromatch/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"arr-diff": "^4.0.0",
|
||||
"array-unique": "^0.3.2",
|
||||
"braces": "^2.3.1",
|
||||
"define-property": "^2.0.2",
|
||||
"extend-shallow": "^3.0.2",
|
||||
"extglob": "^2.0.4",
|
||||
"fragment-cache": "^0.2.1",
|
||||
"kind-of": "^6.0.2",
|
||||
"nanomatch": "^1.2.9",
|
||||
"object.pick": "^1.3.0",
|
||||
"regex-not": "^1.0.0",
|
||||
"snapdragon": "^0.8.1",
|
||||
"to-regex": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bash-match": "^1.0.2",
|
||||
"for-own": "^1.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-format-md": "^1.0.0",
|
||||
"gulp-istanbul": "^1.1.3",
|
||||
"gulp-mocha": "^5.0.0",
|
||||
"gulp-unused": "^0.2.1",
|
||||
"is-windows": "^1.0.2",
|
||||
"minimatch": "^3.0.4",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^3.5.3",
|
||||
"multimatch": "^2.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"bash",
|
||||
"expand",
|
||||
"expansion",
|
||||
"expression",
|
||||
"file",
|
||||
"files",
|
||||
"filter",
|
||||
"find",
|
||||
"glob",
|
||||
"globbing",
|
||||
"globs",
|
||||
"globstar",
|
||||
"match",
|
||||
"matcher",
|
||||
"matches",
|
||||
"matching",
|
||||
"micromatch",
|
||||
"minimatch",
|
||||
"multimatch",
|
||||
"path",
|
||||
"pattern",
|
||||
"patterns",
|
||||
"regex",
|
||||
"regexp",
|
||||
"regular",
|
||||
"shell",
|
||||
"wildcard"
|
||||
],
|
||||
"lintDeps": {
|
||||
"dependencies": {
|
||||
"options": {
|
||||
"lock": {
|
||||
"snapdragon": "^0.8.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"files": {
|
||||
"options": {
|
||||
"ignore": [
|
||||
"benchmark/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"verb": {
|
||||
"toc": "collapsible",
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"helpers": [
|
||||
"./benchmark/helper.js"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"braces",
|
||||
"expand-brackets",
|
||||
"extglob",
|
||||
"fill-range",
|
||||
"nanomatch"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"expand-brackets",
|
||||
"extglob",
|
||||
"glob-object",
|
||||
"minimatch",
|
||||
"multimatch",
|
||||
"snapdragon"
|
||||
]
|
||||
}
|
||||
}
|
21
node_modules/sane/node_modules/normalize-path/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/normalize-path/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, 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.
|
92
node_modules/sane/node_modules/normalize-path/README.md
generated
vendored
Normal file
92
node_modules/sane/node_modules/normalize-path/README.md
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# normalize-path [](https://www.npmjs.com/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://travis-ci.org/jonschlinkert/normalize-path)
|
||||
|
||||
> Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save normalize-path
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var normalize = require('normalize-path');
|
||||
|
||||
normalize('\\foo\\bar\\baz\\');
|
||||
//=> '/foo/bar/baz'
|
||||
|
||||
normalize('./foo/bar/baz/');
|
||||
//=> './foo/bar/baz'
|
||||
```
|
||||
|
||||
Pass `false` as the last argument to **keep** trailing slashes:
|
||||
|
||||
```js
|
||||
normalize('./foo/bar/baz/', false);
|
||||
//=> './foo/bar/baz/'
|
||||
|
||||
normalize('foo\\bar\\baz\\', false);
|
||||
//=> 'foo/bar/baz/'
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path "Return true if a file path contains the given path.")
|
||||
* [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://github.com/jonschlinkert/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with "Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for comparisons.")
|
||||
* [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute "Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute.")
|
||||
* [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative "Returns `true` if the path appears to be relative.")
|
||||
* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Pollyfill for node.js `path.parse`, parses a filepath into an object. | [homepage](https://github.com/jonschlinkert/parse-filepath "Pollyfill for node.js `path.parse`, parses a filepath into an object.")
|
||||
* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with "Return `true` if a file path ends with the given string/suffix.")
|
||||
* [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments "Get n specific segments of a file path, e.g. first 2, last 3, etc.")
|
||||
* [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g… [more](https://github.com/jonschlinkert/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext "Automatically re-write the destination extension of a filepath based on the source extension. e.g `.coffee` => `.js`. This will only rename the ext, no other path parts are modified.")
|
||||
* [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify "Convert Windows file paths to unix paths.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 31 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 1 | [phated](https://github.com/phated) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 29, 2017._
|
19
node_modules/sane/node_modules/normalize-path/index.js
generated
vendored
Normal file
19
node_modules/sane/node_modules/normalize-path/index.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*!
|
||||
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
var removeTrailingSeparator = require('remove-trailing-separator');
|
||||
|
||||
module.exports = function normalizePath(str, stripTrailing) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
str = str.replace(/[\\\/]+/g, '/');
|
||||
if (stripTrailing !== false) {
|
||||
str = removeTrailingSeparator(str);
|
||||
}
|
||||
return str;
|
||||
};
|
78
node_modules/sane/node_modules/normalize-path/package.json
generated
vendored
Normal file
78
node_modules/sane/node_modules/normalize-path/package.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"name": "normalize-path",
|
||||
"description": "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.",
|
||||
"version": "2.1.1",
|
||||
"homepage": "https://github.com/jonschlinkert/normalize-path",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://twitter.com/BlaineBublitz)",
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "jonschlinkert/normalize-path",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/normalize-path/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"remove-trailing-separator": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmarked": "^0.1.1",
|
||||
"gulp-format-md": "^0.1.11",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"backslash",
|
||||
"file",
|
||||
"filepath",
|
||||
"fix",
|
||||
"forward",
|
||||
"fp",
|
||||
"fs",
|
||||
"normalize",
|
||||
"path",
|
||||
"slash",
|
||||
"slashes",
|
||||
"trailing",
|
||||
"unix",
|
||||
"urix"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"contains-path",
|
||||
"ends-with",
|
||||
"is-absolute",
|
||||
"is-relative",
|
||||
"parse-filepath",
|
||||
"path-ends-with",
|
||||
"path-segments",
|
||||
"rewrite-ext",
|
||||
"unixify"
|
||||
],
|
||||
"description": "Other useful libraries for working with paths in node.js:"
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
39
node_modules/sane/node_modules/npm-run-path/index.js
generated
vendored
Normal file
39
node_modules/sane/node_modules/npm-run-path/index.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const pathKey = require('path-key');
|
||||
|
||||
module.exports = opts => {
|
||||
opts = Object.assign({
|
||||
cwd: process.cwd(),
|
||||
path: process.env[pathKey()]
|
||||
}, opts);
|
||||
|
||||
let prev;
|
||||
let pth = path.resolve(opts.cwd);
|
||||
const ret = [];
|
||||
|
||||
while (prev !== pth) {
|
||||
ret.push(path.join(pth, 'node_modules/.bin'));
|
||||
prev = pth;
|
||||
pth = path.resolve(pth, '..');
|
||||
}
|
||||
|
||||
// ensure the running `node` binary is used
|
||||
ret.push(path.dirname(process.execPath));
|
||||
|
||||
return ret.concat(opts.path).join(path.delimiter);
|
||||
};
|
||||
|
||||
module.exports.env = opts => {
|
||||
opts = Object.assign({
|
||||
env: process.env
|
||||
}, opts);
|
||||
|
||||
const env = Object.assign({}, opts.env);
|
||||
const path = pathKey({env});
|
||||
|
||||
opts.path = env[path];
|
||||
env[path] = module.exports(opts);
|
||||
|
||||
return env;
|
||||
};
|
21
node_modules/sane/node_modules/npm-run-path/license
generated
vendored
Normal file
21
node_modules/sane/node_modules/npm-run-path/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
45
node_modules/sane/node_modules/npm-run-path/package.json
generated
vendored
Normal file
45
node_modules/sane/node_modules/npm-run-path/package.json
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "npm-run-path",
|
||||
"version": "2.0.2",
|
||||
"description": "Get your PATH prepended with locally installed binaries",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/npm-run-path",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"npm",
|
||||
"run",
|
||||
"path",
|
||||
"package",
|
||||
"bin",
|
||||
"binary",
|
||||
"binaries",
|
||||
"script",
|
||||
"cli",
|
||||
"command-line",
|
||||
"execute",
|
||||
"executable"
|
||||
],
|
||||
"dependencies": {
|
||||
"path-key": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
81
node_modules/sane/node_modules/npm-run-path/readme.md
generated
vendored
Normal file
81
node_modules/sane/node_modules/npm-run-path/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
# npm-run-path [](https://travis-ci.org/sindresorhus/npm-run-path)
|
||||
|
||||
> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
|
||||
|
||||
In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save npm-run-path
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const childProcess = require('child_process');
|
||||
const npmRunPath = require('npm-run-path');
|
||||
|
||||
console.log(process.env.PATH);
|
||||
//=> '/usr/local/bin'
|
||||
|
||||
console.log(npmRunPath());
|
||||
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
|
||||
|
||||
// `foo` is a locally installed binary
|
||||
childProcess.execFileSync('foo', {
|
||||
env: npmRunPath.env()
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### npmRunPath([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### path
|
||||
|
||||
Type: `string`<br>
|
||||
Default: [`PATH`](https://github.com/sindresorhus/path-key)
|
||||
|
||||
PATH to be appended.<br>
|
||||
Set it to an empty string to exclude the default PATH.
|
||||
|
||||
### npmRunPath.env([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### env
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
|
||||
- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
13
node_modules/sane/node_modules/path-key/index.js
generated
vendored
Normal file
13
node_modules/sane/node_modules/path-key/index.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
module.exports = opts => {
|
||||
opts = opts || {};
|
||||
|
||||
const env = opts.env || process.env;
|
||||
const platform = opts.platform || process.platform;
|
||||
|
||||
if (platform !== 'win32') {
|
||||
return 'PATH';
|
||||
}
|
||||
|
||||
return Object.keys(env).find(x => x.toUpperCase() === 'PATH') || 'Path';
|
||||
};
|
21
node_modules/sane/node_modules/path-key/license
generated
vendored
Normal file
21
node_modules/sane/node_modules/path-key/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
39
node_modules/sane/node_modules/path-key/package.json
generated
vendored
Normal file
39
node_modules/sane/node_modules/path-key/package.json
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "path-key",
|
||||
"version": "2.0.1",
|
||||
"description": "Get the PATH environment variable key cross-platform",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/path-key",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"path",
|
||||
"key",
|
||||
"environment",
|
||||
"env",
|
||||
"variable",
|
||||
"var",
|
||||
"get",
|
||||
"cross-platform",
|
||||
"windows"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
51
node_modules/sane/node_modules/path-key/readme.md
generated
vendored
Normal file
51
node_modules/sane/node_modules/path-key/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# path-key [](https://travis-ci.org/sindresorhus/path-key)
|
||||
|
||||
> Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform
|
||||
|
||||
It's usually `PATH`, but on Windows it can be any casing like `Path`...
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-key
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const pathKey = require('path-key');
|
||||
|
||||
const key = pathKey();
|
||||
//=> 'PATH'
|
||||
|
||||
const PATH = process.env[key];
|
||||
//=> '/usr/local/bin:/usr/bin:/bin'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pathKey([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### env
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env)
|
||||
|
||||
Use a custom environment variables object.
|
||||
|
||||
#### platform
|
||||
|
||||
Type: `string`<br>
|
||||
Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform)
|
||||
|
||||
Get the PATH key for a specific platform.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
39
node_modules/sane/node_modules/semver/CHANGELOG.md
generated
vendored
Normal file
39
node_modules/sane/node_modules/semver/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
# changes log
|
||||
|
||||
## 5.7
|
||||
|
||||
* Add `minVersion` method
|
||||
|
||||
## 5.6
|
||||
|
||||
* Move boolean `loose` param to an options object, with
|
||||
backwards-compatibility protection.
|
||||
* Add ability to opt out of special prerelease version handling with
|
||||
the `includePrerelease` option flag.
|
||||
|
||||
## 5.5
|
||||
|
||||
* Add version coercion capabilities
|
||||
|
||||
## 5.4
|
||||
|
||||
* Add intersection checking
|
||||
|
||||
## 5.3
|
||||
|
||||
* Add `minSatisfying` method
|
||||
|
||||
## 5.2
|
||||
|
||||
* Add `prerelease(v)` that returns prerelease components
|
||||
|
||||
## 5.1
|
||||
|
||||
* Add Backus-Naur for ranges
|
||||
* Remove excessively cute inspection methods
|
||||
|
||||
## 5.0
|
||||
|
||||
* Remove AMD/Browserified build artifacts
|
||||
* Fix ltr and gtr when using the `*` range
|
||||
* Fix for range `*` with a prerelease identifier
|
15
node_modules/sane/node_modules/semver/LICENSE
generated
vendored
Normal file
15
node_modules/sane/node_modules/semver/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
412
node_modules/sane/node_modules/semver/README.md
generated
vendored
Normal file
412
node_modules/sane/node_modules/semver/README.md
generated
vendored
Normal file
|
@ -0,0 +1,412 @@
|
|||
semver(1) -- The semantic versioner for npm
|
||||
===========================================
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install --save semver
|
||||
````
|
||||
|
||||
## Usage
|
||||
|
||||
As a node module:
|
||||
|
||||
```js
|
||||
const semver = require('semver')
|
||||
|
||||
semver.valid('1.2.3') // '1.2.3'
|
||||
semver.valid('a.b.c') // null
|
||||
semver.clean(' =v1.2.3 ') // '1.2.3'
|
||||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
||||
semver.gt('1.2.3', '9.8.7') // false
|
||||
semver.lt('1.2.3', '9.8.7') // true
|
||||
semver.minVersion('>=1.0.0') // '1.0.0'
|
||||
semver.valid(semver.coerce('v2')) // '2.0.0'
|
||||
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
||||
```
|
||||
|
||||
As a command-line utility:
|
||||
|
||||
```
|
||||
$ semver -h
|
||||
|
||||
A JavaScript implementation of the https://semver.org/ specification
|
||||
Copyright Isaac Z. Schlueter
|
||||
|
||||
Usage: semver [options] <version> [<version> [...]]
|
||||
Prints valid versions sorted by SemVer precedence
|
||||
|
||||
Options:
|
||||
-r --range <range>
|
||||
Print versions that match the specified range.
|
||||
|
||||
-i --increment [<level>]
|
||||
Increment a version by the specified level. Level can
|
||||
be one of: major, minor, patch, premajor, preminor,
|
||||
prepatch, or prerelease. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
Identifier to be used to prefix premajor, preminor,
|
||||
prepatch or prerelease version increments.
|
||||
|
||||
-l --loose
|
||||
Interpret versions and ranges loosely
|
||||
|
||||
-p --include-prerelease
|
||||
Always include prerelease versions in range matching
|
||||
|
||||
-c --coerce
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no satisfying versions are found, then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.
|
||||
```
|
||||
|
||||
## Versions
|
||||
|
||||
A "version" is described by the `v2.0.0` specification found at
|
||||
<https://semver.org/>.
|
||||
|
||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
||||
|
||||
## Ranges
|
||||
|
||||
A `version range` is a set of `comparators` which specify versions
|
||||
that satisfy the range.
|
||||
|
||||
A `comparator` is composed of an `operator` and a `version`. The set
|
||||
of primitive `operators` is:
|
||||
|
||||
* `<` Less than
|
||||
* `<=` Less than or equal to
|
||||
* `>` Greater than
|
||||
* `>=` Greater than or equal to
|
||||
* `=` Equal. If no operator is specified, then equality is assumed,
|
||||
so this operator is optional, but MAY be included.
|
||||
|
||||
For example, the comparator `>=1.2.7` would match the versions
|
||||
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
||||
or `1.1.0`.
|
||||
|
||||
Comparators can be joined by whitespace to form a `comparator set`,
|
||||
which is satisfied by the **intersection** of all of the comparators
|
||||
it includes.
|
||||
|
||||
A range is composed of one or more comparator sets, joined by `||`. A
|
||||
version matches a range if and only if every comparator in at least
|
||||
one of the `||`-separated comparator sets is satisfied by the version.
|
||||
|
||||
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
||||
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
||||
or `1.1.0`.
|
||||
|
||||
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
||||
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
||||
|
||||
### Prerelease Tags
|
||||
|
||||
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
||||
it will only be allowed to satisfy comparator sets if at least one
|
||||
comparator with the same `[major, minor, patch]` tuple also has a
|
||||
prerelease tag.
|
||||
|
||||
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
||||
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
||||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
||||
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
||||
range only accepts prerelease tags on the `1.2.3` version. The
|
||||
version `3.4.5` *would* satisfy the range, because it does not have a
|
||||
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
||||
|
||||
The purpose for this behavior is twofold. First, prerelease versions
|
||||
frequently are updated very quickly, and contain many breaking changes
|
||||
that are (by the author's design) not yet fit for public consumption.
|
||||
Therefore, by default, they are excluded from range matching
|
||||
semantics.
|
||||
|
||||
Second, a user who has opted into using a prerelease version has
|
||||
clearly indicated the intent to use *that specific* set of
|
||||
alpha/beta/rc versions. By including a prerelease tag in the range,
|
||||
the user is indicating that they are aware of the risk. However, it
|
||||
is still not appropriate to assume that they have opted into taking a
|
||||
similar risk on the *next* set of prerelease versions.
|
||||
|
||||
Note that this behavior can be suppressed (treating all prerelease
|
||||
versions as if they were normal versions, for the purpose of range
|
||||
matching) by setting the `includePrerelease` flag on the options
|
||||
object to any
|
||||
[functions](https://github.com/npm/node-semver#functions) that do
|
||||
range matching.
|
||||
|
||||
#### Prerelease Identifiers
|
||||
|
||||
The method `.inc` takes an additional `identifier` string argument that
|
||||
will append the value of the string as a prerelease identifier:
|
||||
|
||||
```javascript
|
||||
semver.inc('1.2.3', 'prerelease', 'beta')
|
||||
// '1.2.4-beta.0'
|
||||
```
|
||||
|
||||
command-line example:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.3 -i prerelease --preid beta
|
||||
1.2.4-beta.0
|
||||
```
|
||||
|
||||
Which then can be used to increment further:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.4-beta.0 -i prerelease
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
### Advanced Range Syntax
|
||||
|
||||
Advanced range syntax desugars to primitive comparators in
|
||||
deterministic ways.
|
||||
|
||||
Advanced ranges may be combined in the same way as primitive
|
||||
comparators using white space or `||`.
|
||||
|
||||
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
||||
|
||||
Specifies an inclusive set.
|
||||
|
||||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the first version in the inclusive
|
||||
range, then the missing pieces are replaced with zeroes.
|
||||
|
||||
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the second version in the
|
||||
inclusive range, then all versions that start with the supplied parts
|
||||
of the tuple are accepted, but nothing that would be greater than the
|
||||
provided tuple parts.
|
||||
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
||||
|
||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
||||
|
||||
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
||||
numeric values in the `[major, minor, patch]` tuple.
|
||||
|
||||
* `*` := `>=0.0.0` (Any version satisfies)
|
||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
||||
|
||||
A partial version range is treated as an X-Range, so the special
|
||||
character is in fact optional.
|
||||
|
||||
* `""` (empty string) := `*` := `>=0.0.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
||||
|
||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||
|
||||
Allows patch-level changes if a minor version is specified on the
|
||||
comparator. Allows minor-level changes if not.
|
||||
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
|
||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
||||
|
||||
Allows changes that do not modify the left-most non-zero digit in the
|
||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
||||
minor updates for versions `1.0.0` and above, patch updates for
|
||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
||||
|
||||
Many authors treat a `0.x` version as if the `x` were the major
|
||||
"breaking-change" indicator.
|
||||
|
||||
Caret ranges are ideal when an author may make breaking changes
|
||||
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
||||
However, it presumes that there will *not* be breaking changes between
|
||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
||||
additive (but non-breaking), according to commonly observed practices.
|
||||
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
||||
|
||||
When parsing caret ranges, a missing `patch` value desugars to the
|
||||
number `0`, but will allow flexibility within that value, even if the
|
||||
major and minor versions are both `0`.
|
||||
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
||||
|
||||
A missing `minor` and `patch` values will desugar to zero, but also
|
||||
allow flexibility within those values, even if the major version is
|
||||
zero.
|
||||
|
||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
||||
|
||||
### Range Grammar
|
||||
|
||||
Putting all this together, here is a Backus-Naur grammar for ranges,
|
||||
for the benefit of parser authors:
|
||||
|
||||
```bnf
|
||||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= parts
|
||||
build ::= parts
|
||||
parts ::= part ( '.' part ) *
|
||||
part ::= nr | [-0-9A-Za-z]+
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
All methods and classes take a final `options` object argument. All
|
||||
options in this object are `false` by default. The options supported
|
||||
are:
|
||||
|
||||
- `loose` Be more forgiving about not-quite-valid semver strings.
|
||||
(Any resulting output will always be 100% strict compliant, of
|
||||
course.) For backwards compatibility reasons, if the `options`
|
||||
argument is a boolean value instead of an object, it is interpreted
|
||||
to be the `loose` param.
|
||||
- `includePrerelease` Set to suppress the [default
|
||||
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
||||
excluding prerelease tagged versions from ranges unless they are
|
||||
explicitly opted into.
|
||||
|
||||
Strict-mode Comparators and Ranges will be strict about the SemVer
|
||||
strings that they parse.
|
||||
|
||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
||||
* `inc(v, release)`: Return the version incremented by the release
|
||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
||||
`prepatch`, or `prerelease`), or null if it's not valid
|
||||
* `premajor` in one call will bump the version up to the next major
|
||||
version and down to a prerelease of that major version.
|
||||
`preminor`, and `prepatch` work the same way.
|
||||
* If called from a non-prerelease version, the `prerelease` will work the
|
||||
same as `prepatch`. It increments the patch version, then makes a
|
||||
prerelease. If the input version is already a prerelease it simply
|
||||
increments it.
|
||||
* `prerelease(v)`: Returns an array of prerelease components, or null
|
||||
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
||||
* `major(v)`: Return the major version number.
|
||||
* `minor(v)`: Return the minor version number.
|
||||
* `patch(v)`: Return the patch version number.
|
||||
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
||||
or comparators intersect.
|
||||
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
||||
a `SemVer` object or `null`.
|
||||
|
||||
### Comparison
|
||||
|
||||
* `gt(v1, v2)`: `v1 > v2`
|
||||
* `gte(v1, v2)`: `v1 >= v2`
|
||||
* `lt(v1, v2)`: `v1 < v2`
|
||||
* `lte(v1, v2)`: `v1 <= v2`
|
||||
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
||||
even if they're not the exact same string. You already know how to
|
||||
compare strings.
|
||||
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
||||
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
||||
the corresponding function above. `"==="` and `"!=="` do simple
|
||||
string comparison, but are included for completeness. Throws if an
|
||||
invalid comparison string is provided.
|
||||
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
||||
in descending order when passed to `Array.sort()`.
|
||||
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
||||
or null if the versions are the same.
|
||||
|
||||
### Comparators
|
||||
|
||||
* `intersects(comparator)`: Return true if the comparators intersect
|
||||
|
||||
### Ranges
|
||||
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid
|
||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
||||
range.
|
||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minVersion(range)`: Return the lowest version that can possibly match
|
||||
the given range.
|
||||
* `gtr(version, range)`: Return `true` if version is greater than all the
|
||||
versions possible in the range.
|
||||
* `ltr(version, range)`: Return `true` if version is less than all the
|
||||
versions possible in the range.
|
||||
* `outside(version, range, hilo)`: Return true if the version is outside
|
||||
the bounds of the range in either the high or low direction. The
|
||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||
the function called by `gtr` and `ltr`.)
|
||||
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
||||
|
||||
Note that, since ranges may be non-contiguous, a version might not be
|
||||
greater than a range, less than a range, *or* satisfy a range! For
|
||||
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
||||
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
||||
range (because `2.0.1` satisfies, which is higher), nor less than the
|
||||
range (since `1.2.8` satisfies, which is lower), and it also does not
|
||||
satisfy the range.
|
||||
|
||||
If you want to know if a version satisfies or does not satisfy a
|
||||
range, use the `satisfies(version, range)` function.
|
||||
|
||||
### Coercion
|
||||
|
||||
* `coerce(version)`: Coerces a string to semver if possible
|
||||
|
||||
This aims to provide a very forgiving translation of a non-semver string to
|
||||
semver. It looks for the first digit in a string, and consumes all
|
||||
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
||||
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
||||
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
||||
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
||||
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
||||
is not valid). The maximum length for any semver component considered for
|
||||
coercion is 16 characters; longer components will be ignored
|
||||
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
||||
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
||||
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
28
node_modules/sane/node_modules/semver/package.json
generated
vendored
Normal file
28
node_modules/sane/node_modules/semver/package.json
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "semver",
|
||||
"version": "5.7.1",
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"main": "semver.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --all; git push origin --tags"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^13.0.0-rc.18"
|
||||
},
|
||||
"license": "ISC",
|
||||
"repository": "https://github.com/npm/node-semver",
|
||||
"bin": {
|
||||
"semver": "./bin/semver"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"range.bnf",
|
||||
"semver.js"
|
||||
],
|
||||
"tap": {
|
||||
"check-coverage": true
|
||||
}
|
||||
}
|
16
node_modules/sane/node_modules/semver/range.bnf
generated
vendored
Normal file
16
node_modules/sane/node_modules/semver/range.bnf
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | [1-9] ( [0-9] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= parts
|
||||
build ::= parts
|
||||
parts ::= part ( '.' part ) *
|
||||
part ::= nr | [-0-9A-Za-z]+
|
1483
node_modules/sane/node_modules/semver/semver.js
generated
vendored
Normal file
1483
node_modules/sane/node_modules/semver/semver.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
19
node_modules/sane/node_modules/shebang-command/index.js
generated
vendored
Normal file
19
node_modules/sane/node_modules/shebang-command/index.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
var shebangRegex = require('shebang-regex');
|
||||
|
||||
module.exports = function (str) {
|
||||
var match = str.match(shebangRegex);
|
||||
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var arr = match[0].replace(/#! ?/, '').split(' ');
|
||||
var bin = arr[0].split('/').pop();
|
||||
var arg = arr[1];
|
||||
|
||||
return (bin === 'env' ?
|
||||
arg :
|
||||
bin + (arg ? ' ' + arg : '')
|
||||
);
|
||||
};
|
21
node_modules/sane/node_modules/shebang-command/license
generated
vendored
Normal file
21
node_modules/sane/node_modules/shebang-command/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Martensson <kevinmartensson@gmail.com> (github.com/kevva)
|
||||
|
||||
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.
|
39
node_modules/sane/node_modules/shebang-command/package.json
generated
vendored
Normal file
39
node_modules/sane/node_modules/shebang-command/package.json
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "shebang-command",
|
||||
"version": "1.2.0",
|
||||
"description": "Get the command from a shebang",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/shebang-command",
|
||||
"author": {
|
||||
"name": "Kevin Martensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"cmd",
|
||||
"command",
|
||||
"parse",
|
||||
"shebang"
|
||||
],
|
||||
"dependencies": {
|
||||
"shebang-regex": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
}
|
39
node_modules/sane/node_modules/shebang-command/readme.md
generated
vendored
Normal file
39
node_modules/sane/node_modules/shebang-command/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
# shebang-command [](https://travis-ci.org/kevva/shebang-command)
|
||||
|
||||
> Get the command from a shebang
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save shebang-command
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const shebangCommand = require('shebang-command');
|
||||
|
||||
shebangCommand('#!/usr/bin/env node');
|
||||
//=> 'node'
|
||||
|
||||
shebangCommand('#!/bin/bash');
|
||||
//=> 'bash'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### shebangCommand(string)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
String containing a shebang.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Martensson](http://github.com/kevva)
|
2
node_modules/sane/node_modules/shebang-regex/index.js
generated
vendored
Normal file
2
node_modules/sane/node_modules/shebang-regex/index.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
'use strict';
|
||||
module.exports = /^#!.*/;
|
21
node_modules/sane/node_modules/shebang-regex/license
generated
vendored
Normal file
21
node_modules/sane/node_modules/shebang-regex/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
32
node_modules/sane/node_modules/shebang-regex/package.json
generated
vendored
Normal file
32
node_modules/sane/node_modules/shebang-regex/package.json
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "shebang-regex",
|
||||
"version": "1.0.0",
|
||||
"description": "Regular expression for matching a shebang",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/shebang-regex",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"re",
|
||||
"regex",
|
||||
"regexp",
|
||||
"shebang",
|
||||
"match",
|
||||
"test"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "0.0.4"
|
||||
}
|
||||
}
|
29
node_modules/sane/node_modules/shebang-regex/readme.md
generated
vendored
Normal file
29
node_modules/sane/node_modules/shebang-regex/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
# shebang-regex [](https://travis-ci.org/sindresorhus/shebang-regex)
|
||||
|
||||
> Regular expression for matching a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save shebang-regex
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var shebangRegex = require('shebang-regex');
|
||||
var str = '#!/usr/bin/env node\nconsole.log("unicorns");';
|
||||
|
||||
shebangRegex.test(str);
|
||||
//=> true
|
||||
|
||||
shebangRegex.exec(str)[0];
|
||||
//=> '#!/usr/bin/env node'
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
21
node_modules/sane/node_modules/to-regex-range/LICENSE
generated
vendored
Normal file
21
node_modules/sane/node_modules/to-regex-range/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017, 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.
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue