add linting (and some initial fixes)
This commit is contained in:
parent
963b7a41fe
commit
7fff4499fd
5
Makefile
5
Makefile
@ -7,6 +7,7 @@ pogen = node_modules/pogen/pogen.js
|
||||
typedoc = node_modules/typedoc/bin/typedoc
|
||||
ava = node_modules/ava/cli.js
|
||||
nyc = node_modules/nyc/bin/nyc.js
|
||||
tslint = node_modules/tslint/bin/tslint
|
||||
|
||||
|
||||
.PHONY: package-stable
|
||||
@ -49,7 +50,9 @@ check: tsc yarn-install
|
||||
coverage: tsc yarn-install
|
||||
$(nyc) --all $(ava) 'build/**/*-test.js'
|
||||
|
||||
|
||||
.PHONY: lint
|
||||
lint: tsc yarn-install
|
||||
$(tslint) --type-check --project tsconfig.json -t verbose 'src/**/*.ts'
|
||||
|
||||
.PHONY: yarn-install
|
||||
i18n: yarn-install
|
||||
|
1
node_modules/.bin/ava
generated
vendored
Symbolic link
1
node_modules/.bin/ava
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ava/cli.js
|
1
node_modules/.bin/gulp
generated
vendored
Symbolic link
1
node_modules/.bin/gulp
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../gulp/bin/gulp.js
|
1
node_modules/.bin/nyc
generated
vendored
Symbolic link
1
node_modules/.bin/nyc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../nyc/bin/nyc.js
|
1
node_modules/.bin/po2json
generated
vendored
Symbolic link
1
node_modules/.bin/po2json
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../po2json/bin/po2json
|
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
1
node_modules/.bin/tslint
generated
vendored
Symbolic link
1
node_modules/.bin/tslint
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../tslint/bin/tslint
|
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
1
node_modules/.bin/typedoc
generated
vendored
Symbolic link
1
node_modules/.bin/typedoc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../typedoc/bin/typedoc
|
1
node_modules/.bin/uglifyjs
generated
vendored
Symbolic link
1
node_modules/.bin/uglifyjs
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../uglify-js/bin/uglifyjs
|
1
node_modules/.bin/webpack
generated
vendored
Symbolic link
1
node_modules/.bin/webpack
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../webpack/bin/webpack.js
|
1
node_modules/.yarn-integrity
generated
vendored
Normal file
1
node_modules/.yarn-integrity
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
5efba3465403c140402a7cb917ea321dfbc676f70ff4828f0e6aab87dbefc8c3
|
70
node_modules/@ava/babel-plugin-throws-helper/index.js
generated
vendored
Normal file
70
node_modules/@ava/babel-plugin-throws-helper/index.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = babelCore => {
|
||||
const t = babelCore.types;
|
||||
const wrapArg = babelCore.template('(START(t, ASSERTION, FILE, LINE), END(t, ARG))');
|
||||
const helpers = babelCore.template(`function START(t, assertion, file, line) {
|
||||
if (t._throwsArgStart) {
|
||||
t._throwsArgStart(assertion, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
function END(t, arg) {
|
||||
if (t._throwsArgEnd) {
|
||||
t._throwsArgEnd();
|
||||
}
|
||||
|
||||
return arg;
|
||||
}`);
|
||||
|
||||
const assertionVisitor = {
|
||||
CallExpression(path, state) {
|
||||
const callee = path.get('callee');
|
||||
if (!callee.isMemberExpression() || !callee.get('object').isIdentifier({name: 't'}) || !callee.get('property').isIdentifier()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const assertion = callee.get('property').get('name').node;
|
||||
if (assertion !== 'throws' && assertion !== 'notThrows') {
|
||||
return;
|
||||
}
|
||||
|
||||
const arg0 = path.node.arguments[0];
|
||||
if (!(arg0 && arg0.loc && (typeof arg0.start === 'number') && (typeof arg0.end === 'number'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wrap the argument expression, so that the stack trace of the assertion
|
||||
// isn't affected.
|
||||
path.node.arguments[0] = wrapArg(Object.assign({
|
||||
ARG: arg0,
|
||||
ASSERTION: t.stringLiteral(assertion),
|
||||
FILE: t.stringLiteral(state.file.opts.filename),
|
||||
LINE: t.numericLiteral(arg0.loc.start.line)
|
||||
}, this.installHelper())).expression;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
visitor: {
|
||||
Program(path, state) {
|
||||
const START = t.identifier(path.scope.generateUid('avaThrowsHelperStart'));
|
||||
const END = t.identifier(path.scope.generateUid('avaThrowsHelperEnd'));
|
||||
const helperIdentifiers = {START, END};
|
||||
|
||||
let created = false;
|
||||
path.traverse(assertionVisitor, {
|
||||
installHelper() {
|
||||
if (!created) {
|
||||
created = true;
|
||||
path.unshiftContainer('body', helpers(helperIdentifiers));
|
||||
}
|
||||
|
||||
return helperIdentifiers;
|
||||
},
|
||||
file: state.file
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
21
node_modules/@ava/babel-plugin-throws-helper/license
generated
vendored
Normal file
21
node_modules/@ava/babel-plugin-throws-helper/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
|
||||
|
||||
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.
|
35
node_modules/@ava/babel-plugin-throws-helper/package.json
generated
vendored
Normal file
35
node_modules/@ava/babel-plugin-throws-helper/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@ava/babel-plugin-throws-helper",
|
||||
"version": "2.0.0",
|
||||
"description": "Babel plugin for protecting against improper use of `t.throws()` in AVA",
|
||||
"license": "MIT",
|
||||
"repository": "avajs/babel-plugin-throws-helper",
|
||||
"author": {
|
||||
"name": "James Talmage",
|
||||
"email": "james@talmage.io",
|
||||
"url": "github.com/jamestalmage"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"preversion": "WRITE_EXAMPLES=1 npm run test && git add example-output.md"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"babel-plugin",
|
||||
"babel",
|
||||
"helper",
|
||||
"ava",
|
||||
"assertion",
|
||||
"throws"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^0.18.2",
|
||||
"babel-core": "^6.7.5",
|
||||
"xo": "^0.17.0"
|
||||
}
|
||||
}
|
33
node_modules/@ava/babel-plugin-throws-helper/readme.md
generated
vendored
Normal file
33
node_modules/@ava/babel-plugin-throws-helper/readme.md
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
# babel-plugin-throws-helper [![Build Status](https://travis-ci.org/avajs/babel-plugin-throws-helper.svg?branch=master)](https://travis-ci.org/avajs/babel-plugin-throws-helper)
|
||||
|
||||
> Babel plugin for protecting against improper use of `t.throws()` in [AVA](https://ava.li)
|
||||
|
||||
Probably not useful except as an internal plugin for the AVA test runner.
|
||||
|
||||
[Genesis of the idea.](https://github.com/sindresorhus/eslint-plugin-ava/issues/75)
|
||||
|
||||
## Issue
|
||||
|
||||
> I've seen a lot of incorrect use of the throws assertion in other test runner and even done the mistake myself sometimes. Now I'm beginning to see it with AVA too, so would be nice to be preemptive about it.
|
||||
>
|
||||
> People don't realize they need to wrap their call in a function, so many end up doing `t.throws(foo())` instead of `t.throws(() => foo());`. It's an easy mistake to make.
|
||||
|
||||
The difficulty is that `t.throws(foo())` is allowed if `foo()` returns a promise or a function. There is no good way to differentiate between the two at runtime. So providing a good error message is going to take some AST transform magic.
|
||||
|
||||
|
||||
## Solution
|
||||
|
||||
See [`example-output.md`](example-output.md) for the transformation this plugin performs.
|
||||
|
||||
The example output can be generated by calling:
|
||||
|
||||
```
|
||||
$ WRITE_EXAMPLES=1 ava
|
||||
```
|
||||
|
||||
Contributors should not commit new examples. They will be regenerated as part of the release process.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [James Talmage](https://github.com/jamestalmage)
|
9
node_modules/@ava/babel-preset-stage-4/index.js
generated
vendored
Normal file
9
node_modules/@ava/babel-preset-stage-4/index.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
/* eslint-disable import/no-dynamic-require */
|
||||
function buildPreset() {
|
||||
const plugins = require(`./plugins/best-match`)
|
||||
.map(module => require(module));
|
||||
|
||||
return {plugins};
|
||||
}
|
||||
module.exports = buildPreset;
|
21
node_modules/@ava/babel-preset-stage-4/license
generated
vendored
Normal file
21
node_modules/@ava/babel-preset-stage-4/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Mark Wubben <mark@novemberborn.net> (novemberborn.net)
|
||||
|
||||
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.
|
14
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/LICENSE
generated
vendored
Normal file
14
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/LICENSE
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
ISC License (ISC)
|
||||
Copyright (c) 2016, Mark Wubben
|
||||
|
||||
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.
|
72
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/README.md
generated
vendored
Normal file
72
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/README.md
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# package-hash
|
||||
|
||||
Generates a hash for an installed npm package, useful for salting caches.
|
||||
[AVA](https://github.com/sindresorhus/ava) for example caches precompiled test
|
||||
files. It generates a salt for its cache based on the various packages that are
|
||||
used when compiling the test files.
|
||||
|
||||
`package-hash` can generate an appropriate hash based on the package location
|
||||
(on disk) and the `package.json` file. This hash is salted with a hash
|
||||
for the `package-hash` itself.
|
||||
|
||||
`package-hash` can detect when the package-to-be-hashed is a Git repository. In
|
||||
the AVA example this is useful when you're debugging one of the packages used to
|
||||
compile the test files. You can clone it locally and use `npm link` so AVA can
|
||||
find the clone. The hash will include the HEAD (`.git/HEAD`) and its
|
||||
corresponding ref (e.g. `.git/refs/heads/master`), any packed refs
|
||||
(`.git/packed-refs`), as well as the diff (`git diff`) for any non-committed
|
||||
changes. This makes it really easy to test your changes without having to
|
||||
explicitly clear the cache in the parent project.
|
||||
|
||||
## Installation
|
||||
|
||||
```console
|
||||
$ npm install --save package-hash
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const sync = require('package-hash').sync
|
||||
|
||||
const hash = sync(require.resolve('babel-core/package.json'))
|
||||
```
|
||||
|
||||
`sync()` can be called with a directory or file path. File paths are translated
|
||||
to directories using
|
||||
[`path.dirname()`](https://nodejs.org/api/path.html#path_path_dirname_p). The
|
||||
path must exist. A `package.json` must exist within the directory.
|
||||
|
||||
To get the path to an npm package it's best to use
|
||||
`require.resolve('the-name/package.json')`, since `require.resolve('the-name')`
|
||||
may resolve to a subdirectory of the package.
|
||||
|
||||
You can provide multiple paths:
|
||||
|
||||
```js
|
||||
const hash = sync([
|
||||
require.resolve('babel-core/package.json'),
|
||||
require.resolve('babel-preset-es2015/package.json')
|
||||
])
|
||||
```
|
||||
|
||||
An optional salt value can also be provided:
|
||||
|
||||
```js
|
||||
const hash = sync(require.resolve('babel-core/package.json'), 'salt value')
|
||||
```
|
||||
|
||||
Currently only a synchronous interface is available.
|
||||
|
||||
## API
|
||||
|
||||
### `sync(paths, salt?)`
|
||||
|
||||
`paths: string | string[]` ➜ can be a single directory or file path, or an array of paths.
|
||||
|
||||
`salt: Array | Buffer | Object | string` ➜ optional. If an `Array` or `Object` (not `null`) it is first converted to a JSON string.
|
||||
|
||||
## Compatibility
|
||||
|
||||
`package-hash` has been tested with Node 0.10 and above, including Windows
|
||||
support. Note that `git diff` support is not available in Node 0.10.
|
125
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/index.js
generated
vendored
Normal file
125
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/index.js
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
exports.sync = sync;
|
||||
|
||||
var _child_process = require('child_process');
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _md5Hex = require('md5-hex');
|
||||
|
||||
var _md5Hex2 = _interopRequireDefault(_md5Hex);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function tryReadFileSync(file) {
|
||||
try {
|
||||
return (0, _fs.readFileSync)(file);
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var TEN_MEBIBYTE = 1024 * 1024 * 10;
|
||||
|
||||
var git = {
|
||||
tryGetRef: function (dir, head) {
|
||||
var m = /^ref: (.+)$/.exec(head.toString('utf8').trim());
|
||||
if (!m) return null;
|
||||
|
||||
return tryReadFileSync((0, _path.join)(dir, '.git', m[1]));
|
||||
},
|
||||
tryGetDiff: function (dir) {
|
||||
if (!_child_process.execFileSync) return null;
|
||||
|
||||
try {
|
||||
// Attempt to get consistent output no matter the platform. Diff both
|
||||
// staged and unstaged changes.
|
||||
return (0, _child_process.execFileSync)('git', ['--no-pager', 'diff', 'HEAD', '--no-color', '--no-ext-diff'], {
|
||||
cwd: dir,
|
||||
maxBuffer: TEN_MEBIBYTE,
|
||||
env: _extends({}, process.env, {
|
||||
// Force the GIT_DIR to prevent git from diffing a parent repository
|
||||
// in case the directory isn't actually a repository.
|
||||
GIT_DIR: (0, _path.join)(dir, '.git')
|
||||
}),
|
||||
// Ignore stderr.
|
||||
stdio: ['ignore', 'pipe', 'ignore']
|
||||
});
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function addPackageData(inputs, path) {
|
||||
var dir = (0, _fs.statSync)(path).isDirectory() ? path : (0, _path.dirname)(path);
|
||||
inputs.push(dir);
|
||||
|
||||
var pkg = (0, _fs.readFileSync)((0, _path.join)(dir, 'package.json'));
|
||||
inputs.push(pkg);
|
||||
|
||||
var head = tryReadFileSync((0, _path.join)(dir, '.git', 'HEAD'));
|
||||
if (head) {
|
||||
inputs.push(head);
|
||||
|
||||
var packed = tryReadFileSync((0, _path.join)(dir, '.git', 'packed-refs'));
|
||||
if (packed) inputs.push(packed);
|
||||
|
||||
var ref = git.tryGetRef(dir, head);
|
||||
if (ref) inputs.push(ref);
|
||||
|
||||
var diff = git.tryGetDiff(dir);
|
||||
if (diff) inputs.push(diff);
|
||||
}
|
||||
}
|
||||
|
||||
function computeHash(paths, pepper, salt) {
|
||||
var inputs = [];
|
||||
if (pepper) inputs.push(pepper);
|
||||
|
||||
if (typeof salt !== 'undefined') {
|
||||
if (Buffer.isBuffer(salt) || typeof salt === 'string') {
|
||||
inputs.push(salt);
|
||||
} else if (typeof salt === 'object' && salt !== null) {
|
||||
inputs.push(JSON.stringify(salt));
|
||||
} else {
|
||||
throw new TypeError('Salt must be an Array, Buffer, Object or string');
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
addPackageData(inputs, paths[i]);
|
||||
}
|
||||
|
||||
return (0, _md5Hex2.default)(inputs);
|
||||
}
|
||||
|
||||
var ownHash = null;
|
||||
function sync(paths, salt) {
|
||||
if (!ownHash) {
|
||||
// Memoize the hash for package-hash itself.
|
||||
ownHash = new Buffer(computeHash([__dirname]), 'hex');
|
||||
}
|
||||
|
||||
if (paths === __dirname && typeof salt === 'undefined') {
|
||||
// Special case that allow the pepper value to be obtained. Mainly here for
|
||||
// testing purposes.
|
||||
return ownHash.toString('hex');
|
||||
}
|
||||
|
||||
if (Array.isArray(paths)) {
|
||||
return computeHash(paths, ownHash, salt);
|
||||
} else {
|
||||
return computeHash([paths], ownHash, salt);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/index.js.map
generated
vendored
Normal file
1
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
74
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/package.json
generated
vendored
Normal file
74
node_modules/@ava/babel-preset-stage-4/node_modules/package-hash/package.json
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "package-hash",
|
||||
"version": "1.2.0",
|
||||
"description": "Generates a hash for an installed npm package, useful for salting caches",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.js.map"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf index.js index.js.map",
|
||||
"prebuild": "npm run clean",
|
||||
"build": "babel src --out-dir ./ --source-maps",
|
||||
"prepublish": "npm run build",
|
||||
"lint": "as-i-preach",
|
||||
"unpack-fixtures": "node scripts/unpack-fixtures.js",
|
||||
"pregenerate-fixture-index": "npm run unpack-fixtures",
|
||||
"generate-fixture-index": "node scripts/generate-fixture-index.js",
|
||||
"pretest": "npm run unpack-fixtures",
|
||||
"test": "ava",
|
||||
"posttest": "npm run lint",
|
||||
"coverage": "nyc npm test",
|
||||
"watch:build": "npm run build -- --watch",
|
||||
"watch:test": "npm run test -- --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/novemberborn/package-hash.git"
|
||||
},
|
||||
"author": "Mark Wubben (https://novemberborn.net/)",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/novemberborn/package-hash/issues"
|
||||
},
|
||||
"homepage": "https://github.com/novemberborn/package-hash#readme",
|
||||
"dependencies": {
|
||||
"md5-hex": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@novemberborn/as-i-preach": "^2.0.1",
|
||||
"ava": "^0.14.0",
|
||||
"babel-cli": "^6.7.5",
|
||||
"babel-plugin-transform-es2015-block-scoping": "^6.7.1",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.4",
|
||||
"babel-plugin-transform-es2015-shorthand-properties": "^6.5.0",
|
||||
"babel-plugin-transform-object-assign": "^6.5.0",
|
||||
"babel-plugin-transform-strict-mode": "^6.6.5",
|
||||
"nyc": "^6.4.0",
|
||||
"proxyquire": "^1.7.4",
|
||||
"rimraf": "^2.5.2",
|
||||
"tar": "^2.2.1"
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"transform-object-assign",
|
||||
"transform-es2015-block-scoping",
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es2015-shorthand-properties",
|
||||
"transform-strict-mode"
|
||||
]
|
||||
},
|
||||
"nyc": {
|
||||
"cache": true,
|
||||
"exclude": [
|
||||
"scripts",
|
||||
"test"
|
||||
],
|
||||
"reporter": [
|
||||
"html",
|
||||
"lcov",
|
||||
"text"
|
||||
]
|
||||
}
|
||||
}
|
7
node_modules/@ava/babel-preset-stage-4/package-hash.js
generated
vendored
Normal file
7
node_modules/@ava/babel-preset-stage-4/package-hash.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
const packageHash = require('package-hash');
|
||||
|
||||
const plugins = require('./plugins/best-match')
|
||||
.map(module => require.resolve(`${module}/package.json`));
|
||||
|
||||
module.exports = packageHash.sync([require.resolve('./package.json')].concat(plugins));
|
61
node_modules/@ava/babel-preset-stage-4/package.json
generated
vendored
Normal file
61
node_modules/@ava/babel-preset-stage-4/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "@ava/babel-preset-stage-4",
|
||||
"version": "1.0.0",
|
||||
"description": "Efficiently applies the minimum of transforms to run stage 4 code on Node.js 4 and 6",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"package-hash.js",
|
||||
"plugins"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "ava",
|
||||
"posttest": "xo",
|
||||
"coverage": "nyc npm test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/avajs/babel-preset-stage-4.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ava",
|
||||
"babel-preset"
|
||||
],
|
||||
"author": "Mark Wubben (https://novemberborn.net/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/avajs/babel-preset-stage-4/issues"
|
||||
},
|
||||
"homepage": "https://github.com/avajs/babel-preset-stage-4#readme",
|
||||
"devDependencies": {
|
||||
"ava": "^0.17.0",
|
||||
"coveralls": "^2.11.15",
|
||||
"nyc": "^10.1.2",
|
||||
"proxyquire": "^1.7.10",
|
||||
"xo": "^0.17.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-plugin-check-es2015-constants": "^6.8.0",
|
||||
"babel-plugin-syntax-trailing-function-commas": "^6.20.0",
|
||||
"babel-plugin-transform-async-to-generator": "^6.16.0",
|
||||
"babel-plugin-transform-es2015-destructuring": "^6.19.0",
|
||||
"babel-plugin-transform-es2015-function-name": "^6.9.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
|
||||
"babel-plugin-transform-es2015-parameters": "^6.21.0",
|
||||
"babel-plugin-transform-es2015-spread": "^6.8.0",
|
||||
"babel-plugin-transform-es2015-sticky-regex": "^6.8.0",
|
||||
"babel-plugin-transform-es2015-unicode-regex": "^6.11.0",
|
||||
"babel-plugin-transform-exponentiation-operator": "^6.8.0",
|
||||
"package-hash": "^1.2.0"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"html",
|
||||
"lcov",
|
||||
"text"
|
||||
]
|
||||
}
|
||||
}
|
13
node_modules/@ava/babel-preset-stage-4/plugins/4.json
generated
vendored
Normal file
13
node_modules/@ava/babel-preset-stage-4/plugins/4.json
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
"babel-plugin-check-es2015-constants",
|
||||
"babel-plugin-syntax-trailing-function-commas",
|
||||
"babel-plugin-transform-async-to-generator",
|
||||
"babel-plugin-transform-es2015-destructuring",
|
||||
"babel-plugin-transform-es2015-function-name",
|
||||
"babel-plugin-transform-es2015-modules-commonjs",
|
||||
"babel-plugin-transform-es2015-parameters",
|
||||
"babel-plugin-transform-es2015-spread",
|
||||
"babel-plugin-transform-es2015-sticky-regex",
|
||||
"babel-plugin-transform-es2015-unicode-regex",
|
||||
"babel-plugin-transform-exponentiation-operator"
|
||||
]
|
6
node_modules/@ava/babel-preset-stage-4/plugins/6.json
generated
vendored
Normal file
6
node_modules/@ava/babel-preset-stage-4/plugins/6.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
"babel-plugin-syntax-trailing-function-commas",
|
||||
"babel-plugin-transform-async-to-generator",
|
||||
"babel-plugin-transform-es2015-modules-commonjs",
|
||||
"babel-plugin-transform-exponentiation-operator"
|
||||
]
|
15
node_modules/@ava/babel-preset-stage-4/plugins/best-match.js
generated
vendored
Normal file
15
node_modules/@ava/babel-preset-stage-4/plugins/best-match.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
/* eslint-disable import/no-dynamic-require, import/no-unresolved */
|
||||
const process = require('process');
|
||||
|
||||
function getClosestVersion() {
|
||||
const version = parseFloat(process.versions.node);
|
||||
if (version >= 6) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
// Node.js 4 is the minimal supported version.
|
||||
return 4;
|
||||
}
|
||||
|
||||
module.exports = require(`./${getClosestVersion()}.json`);
|
34
node_modules/@ava/babel-preset-stage-4/readme.md
generated
vendored
Normal file
34
node_modules/@ava/babel-preset-stage-4/readme.md
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# @ava/babel-preset-stage-4
|
||||
|
||||
A [Babel] preset for use with [AVA]. Aspires to bring ECMAScript stage 4
|
||||
proposals to AVA's test and helper files.
|
||||
|
||||
Efficiently applies the minimum of transforms to run stage 4 code on Node.js 4
|
||||
and 6.
|
||||
|
||||
Built-ins are not added or extended, so features like Proxies,
|
||||
`Array.prototype.includes` or `String.prototype.padStart` will only be available
|
||||
if the Node.js version running the tests supports it. Consult [node.green] for
|
||||
details.
|
||||
|
||||
Sometimes a particular feature is *mostly* implemented in Node.js. In that case
|
||||
transforms are not applied. This applies to `new.target` and iterator closing,
|
||||
which are not supported in Node.js 4 even though classes and iterators are.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
$ npm install --save @ava/babel-preset-stage-4
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add `@ava/stage-4` to your [Babel] presets.
|
||||
|
||||
Require `@ava/babel-preset-stage-4/package-hash` to get a combined hash for the
|
||||
installed version of the preset, as well as the plugins that were selected for
|
||||
the active Node.js version.
|
||||
|
||||
[AVA]: https://ava.li
|
||||
[Babel]: https://babeljs.io/
|
||||
[node.green]: http://node.green/
|
8
node_modules/@ava/babel-preset-transform-test-files/espower-patterns.json
generated
vendored
Normal file
8
node_modules/@ava/babel-preset-transform-test-files/espower-patterns.json
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
[
|
||||
"t.truthy(value, [message])",
|
||||
"t.falsy(value, [message])",
|
||||
"t.true(value, [message])",
|
||||
"t.false(value, [message])",
|
||||
"t.regex(contents, regex, [message])",
|
||||
"t.notRegex(contents, regex, [message])"
|
||||
]
|
17
node_modules/@ava/babel-preset-transform-test-files/index.js
generated
vendored
Normal file
17
node_modules/@ava/babel-preset-transform-test-files/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
const ESPOWER_PATTERNS = require('./espower-patterns.json');
|
||||
|
||||
module.exports = (context, options) => {
|
||||
const plugins = [];
|
||||
|
||||
if (!options || options.powerAssert !== false) {
|
||||
plugins.push(require('babel-plugin-espower/create')(context, {
|
||||
embedAst: true,
|
||||
patterns: ESPOWER_PATTERNS
|
||||
}));
|
||||
}
|
||||
|
||||
plugins.push(require('@ava/babel-plugin-throws-helper'));
|
||||
|
||||
return {plugins};
|
||||
};
|
21
node_modules/@ava/babel-preset-transform-test-files/license
generated
vendored
Normal file
21
node_modules/@ava/babel-preset-transform-test-files/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Mark Wubben <mark@novemberborn.net> (novemberborn.net)
|
||||
|
||||
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.
|
47
node_modules/@ava/babel-preset-transform-test-files/package.json
generated
vendored
Normal file
47
node_modules/@ava/babel-preset-transform-test-files/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@ava/babel-preset-transform-test-files",
|
||||
"version": "3.0.0",
|
||||
"description": "Babel preset for use with AVA test files",
|
||||
"license": "MIT",
|
||||
"repository": "avajs/babel-preset-transform-test-files",
|
||||
"author": "Mark Wubben (https://novemberborn.net)",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"posttest": "xo",
|
||||
"coverage": "nyc npm test"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"espower-patterns.json",
|
||||
"package-hash.js"
|
||||
],
|
||||
"keywords": [
|
||||
"ava",
|
||||
"babel-preset"
|
||||
],
|
||||
"dependencies": {
|
||||
"@ava/babel-plugin-throws-helper": "^2.0.0",
|
||||
"babel-plugin-espower": "^2.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.18.2",
|
||||
"babel-core": "^6.21.0",
|
||||
"coveralls": "^2.11.15",
|
||||
"empower-core": "^0.6.1",
|
||||
"nyc": "^10.1.2",
|
||||
"xo": "^0.18.1"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"html",
|
||||
"lcov",
|
||||
"text"
|
||||
]
|
||||
}
|
||||
}
|
34
node_modules/@ava/babel-preset-transform-test-files/readme.md
generated
vendored
Normal file
34
node_modules/@ava/babel-preset-transform-test-files/readme.md
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# @ava/babel-preset-transform-test-files [![Build Status](https://travis-ci.org/avajs/babel-preset-transform-test-files.svg?branch=master)](https://travis-ci.org/avajs/babel-preset-transform-test-files)
|
||||
|
||||
> [Babel] preset for use with [AVA] test files
|
||||
|
||||
Currently contains:
|
||||
|
||||
- [`babel-plugin-espower`](https://github.com/power-assert-js/babel-plugin-espower) and the patterns that should be enhanced
|
||||
- [`@ava/babel-plugin-throws-helper`](https://github.com/avajs/babel-plugin-throws-helper/)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
$ npm install --save @ava/babel-preset-transform-test-files
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Add `@ava/transform-test-files` to your [Babel] presets. You can disable `babel-plugin-espower` by setting the `powerAssert` option to `false`:
|
||||
|
||||
```json
|
||||
{
|
||||
"presets": [
|
||||
["@ava/transform-test-files", {"powerAsssert": false}]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Require `@ava/babel-preset-transform-test-files/package-hash` to get a combined hash for the installed version of the preset, as well as the plugins used.
|
||||
|
||||
|
||||
[AVA]: https://ava.li
|
||||
[Babel]: https://babeljs.io
|
3
node_modules/@ava/pretty-format/.npmignore
generated
vendored
Normal file
3
node_modules/@ava/pretty-format/.npmignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
__tests__
|
||||
perf
|
||||
.travis.yml
|
15
node_modules/@ava/pretty-format/LICENSE.md
generated
vendored
Executable file
15
node_modules/@ava/pretty-format/LICENSE.md
generated
vendored
Executable file
@ -0,0 +1,15 @@
|
||||
## ISC License
|
||||
|
||||
Copyright (c) 2016, James Kyle <me@thejameskyle.com>
|
||||
|
||||
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.
|
134
node_modules/@ava/pretty-format/README.md
generated
vendored
Executable file
134
node_modules/@ava/pretty-format/README.md
generated
vendored
Executable file
@ -0,0 +1,134 @@
|
||||
# @ava/pretty-format [![Travis build status](http://img.shields.io/travis/avajs/pretty-format.svg?style=flat)](https://travis-ci.org/avajs/pretty-format)
|
||||
|
||||
> Stringify any JavaScript value.
|
||||
|
||||
- Supports [all built-in JavaScript types](#type-support)
|
||||
- [Blazingly fast](https://gist.github.com/thejameskyle/2b04ffe4941aafa8f970de077843a8fd) (similar performance to v8's `JSON.stringify` and significantly faster than Node's `util.format`)
|
||||
- Plugin system for extending with custom types (i.e. [`ReactTestComponent`](#reacttestcomponent-plugin))
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install @ava/pretty-format
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var prettyFormat = require('pretty-format');
|
||||
|
||||
var obj = { property: {} };
|
||||
obj.circularReference = obj;
|
||||
obj[Symbol('foo')] = 'foo';
|
||||
obj.map = new Map();
|
||||
obj.map.set('prop', 'value');
|
||||
obj.array = [1, NaN, Infinity];
|
||||
|
||||
console.log(prettyFormat(obj));
|
||||
```
|
||||
|
||||
**Result:**
|
||||
|
||||
```js
|
||||
Object {
|
||||
"property": Object {},
|
||||
"circularReference": [Circular],
|
||||
"map": Map {
|
||||
"prop" => "value"
|
||||
},
|
||||
"array": Array [
|
||||
1,
|
||||
NaN,
|
||||
Infinity
|
||||
],
|
||||
Symbol(foo): "foo"
|
||||
}
|
||||
```
|
||||
|
||||
#### Type Support
|
||||
|
||||
`Object`, `Array`, `ArrayBuffer`, `DataView`, `Float32Array`, `Float64Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Uint8Array`, `Uint8ClampedArray`, `Uint16Array`, `Uint32Array`, `arguments`, `Boolean`, `Date`, `Error`, `Function`, `Infinity`, `Map`, `NaN`, `null`, `Number`, `RegExp`, `Set`, `String`, `Symbol`, `undefined`, `WeakMap`, `WeakSet`
|
||||
|
||||
### API
|
||||
|
||||
```js
|
||||
console.log(prettyFormat(object));
|
||||
console.log(prettyFormat(object, options));
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
* **`callToJSON`**<br>
|
||||
Type: `boolean`, default: `true`<br>
|
||||
Call `toJSON()` on passed object.
|
||||
* **`indent`**<br>
|
||||
Type: `number`, default: `2`<br>
|
||||
Number of spaces for indentation.
|
||||
* **`maxDepth`**<br>
|
||||
Type: `number`, default: `Infinity`<br>
|
||||
Print only this number of levels.
|
||||
* **`min`**<br>
|
||||
Type: `boolean`, default: `false`<br>
|
||||
Print without whitespace.
|
||||
* **`plugins`**<br>
|
||||
Type: `array`, default: `[]`<br>
|
||||
Plugins (see the next section).
|
||||
* **`printFunctionName`**<br>
|
||||
Type: `boolean`, default: `true`<br>
|
||||
Print function names or just `[Function]`.
|
||||
* **`escapeRegex`**<br>
|
||||
Type: `boolean`, default: `false`<br>
|
||||
Escape special characters in regular expressions.
|
||||
* **`highlight`**<br>
|
||||
Type: `boolean`, default: `false`<br>
|
||||
Highlight syntax for terminal (works only with `ReactTestComponent` and `ReactElement` plugins.
|
||||
* **`theme`**<br>
|
||||
Type: `object`, default: `{tag: 'cyan', content: 'reset'...}`<br>
|
||||
Syntax highlight theme.<br>
|
||||
Uses [ansi-styles colors](https://github.com/chalk/ansi-styles#colors) + `reset` for no color.<br>
|
||||
Available types: `tag`, `content`, `prop` and `value`.
|
||||
|
||||
### Plugins
|
||||
|
||||
Pretty format also supports adding plugins:
|
||||
|
||||
```js
|
||||
var fooPlugin = {
|
||||
test: function(val) {
|
||||
return val && val.hasOwnProperty('foo');
|
||||
},
|
||||
print: function(val, print, indent) {
|
||||
return 'Foo: ' + print(val.foo);
|
||||
}
|
||||
};
|
||||
|
||||
var obj = { foo: { bar: {} } };
|
||||
|
||||
prettyFormat(obj, {
|
||||
plugins: [fooPlugin]
|
||||
});
|
||||
// Foo: Object {
|
||||
// "bar": Object {}
|
||||
// }
|
||||
```
|
||||
|
||||
#### `ReactTestComponent` and `ReactElement` plugins
|
||||
|
||||
```js
|
||||
var prettyFormat = require('pretty-format');
|
||||
var reactTestPlugin = require('pretty-format/plugins/ReactTestComponent');
|
||||
var reactElementPlugin = require('pretty-format/plugins/ReactElement');
|
||||
|
||||
var React = require('react');
|
||||
var renderer = require('react-test-renderer');
|
||||
|
||||
var jsx = React.createElement('h1', null, 'Hello World');
|
||||
|
||||
prettyFormat(renderer.create(jsx).toJSON(), {
|
||||
plugins: [reactTestPlugin, reactElementPlugin]
|
||||
});
|
||||
// <h1>
|
||||
// Hello World
|
||||
// </h1>
|
||||
```
|
397
node_modules/@ava/pretty-format/index.js
generated
vendored
Normal file
397
node_modules/@ava/pretty-format/index.js
generated
vendored
Normal file
@ -0,0 +1,397 @@
|
||||
'use strict';
|
||||
|
||||
const keyword = require('esutils').keyword;
|
||||
const style = require('ansi-styles');
|
||||
const printString = require('./printString');
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
const toISOString = Date.prototype.toISOString;
|
||||
const errorToString = Error.prototype.toString;
|
||||
const regExpToString = RegExp.prototype.toString;
|
||||
const symbolToString = Symbol.prototype.toString;
|
||||
|
||||
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
||||
const NEWLINE_REGEXP = /\n/ig;
|
||||
|
||||
const getSymbols = Object.getOwnPropertySymbols || (obj => []);
|
||||
|
||||
function isToStringedArrayType(toStringed) {
|
||||
return (
|
||||
toStringed === '[object Array]' ||
|
||||
toStringed === '[object ArrayBuffer]' ||
|
||||
toStringed === '[object DataView]' ||
|
||||
toStringed === '[object Float32Array]' ||
|
||||
toStringed === '[object Float64Array]' ||
|
||||
toStringed === '[object Int8Array]' ||
|
||||
toStringed === '[object Int16Array]' ||
|
||||
toStringed === '[object Int32Array]' ||
|
||||
toStringed === '[object Uint8Array]' ||
|
||||
toStringed === '[object Uint8ClampedArray]' ||
|
||||
toStringed === '[object Uint16Array]' ||
|
||||
toStringed === '[object Uint32Array]'
|
||||
);
|
||||
}
|
||||
|
||||
function printNumber(val) {
|
||||
if (val != +val) return 'NaN';
|
||||
const isNegativeZero = val === 0 && (1 / val) < 0;
|
||||
return isNegativeZero ? '-0' : '' + val;
|
||||
}
|
||||
|
||||
function printFunction(val, printFunctionName) {
|
||||
if (!printFunctionName) {
|
||||
return '[Function]';
|
||||
} else if (val.name === '') {
|
||||
return '[Function anonymous]'
|
||||
} else {
|
||||
return '[Function ' + val.name + ']';
|
||||
}
|
||||
}
|
||||
|
||||
function printSymbol(val) {
|
||||
return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
||||
}
|
||||
|
||||
function printError(val) {
|
||||
return '[' + errorToString.call(val) + ']';
|
||||
}
|
||||
|
||||
function printBasicValue(val, printFunctionName, escapeRegex, colors) {
|
||||
if (val === true || val === false) return colors.boolean.open + val + colors.boolean.close;
|
||||
if (val === undefined) return colors.misc.open + 'undefined' + colors.misc.close;
|
||||
if (val === null) return colors.misc.open + 'null' + colors.misc.close;
|
||||
|
||||
const typeOf = typeof val;
|
||||
|
||||
if (typeOf === 'number') return colors.number.open + printNumber(val) + colors.number.close;
|
||||
if (typeOf === 'string') return colors.string.open + '"' + printString(val) + '"' + colors.string.close;
|
||||
if (typeOf === 'function') return colors.function.open + printFunction(val, printFunctionName) + colors.function.close;
|
||||
if (typeOf === 'symbol') return colors.symbol.open + printSymbol(val) + colors.symbol.close;
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
|
||||
if (toStringed === '[object WeakMap]') return colors.label.open + 'WeakMap ' + colors.label.close + colors.bracket.open + '{}' + colors.bracket.close;
|
||||
if (toStringed === '[object WeakSet]') return colors.label.open + 'WeakSet ' + colors.label.close + colors.bracket.open + '{}' + colors.bracket.close;
|
||||
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return colors.function.open + printFunction(val, printFunctionName) + colors.function.close;
|
||||
if (toStringed === '[object Symbol]') return colors.symbol.open + printSymbol(val) + colors.symbol.close;
|
||||
if (toStringed === '[object Date]') return colors.date.open + toISOString.call(val) + colors.date.close;
|
||||
if (toStringed === '[object Error]') return colors.error.open + printError(val) + colors.error.close;
|
||||
if (toStringed === '[object RegExp]') {
|
||||
if (escapeRegex) {
|
||||
return colors.regex.open + printString(regExpToString.call(val)) + colors.regex.close;
|
||||
}
|
||||
return colors.regex.open + regExpToString.call(val) + colors.regex.close;
|
||||
};
|
||||
if (toStringed === '[object Arguments]' && val.length === 0) return colors.label.open + 'Arguments ' + colors.label.close + colors.bracket.open + '[]' + colors.bracket.close;
|
||||
if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + colors.bracket.open + ' []' + colors.bracket.close;
|
||||
|
||||
if (val instanceof Error) return colors.error.open + printError(val) + colors.error.close;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
let body = '';
|
||||
|
||||
if (list.length) {
|
||||
body += edgeSpacing;
|
||||
|
||||
const innerIndent = prevIndent + indent;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
|
||||
if (i < list.length - 1) {
|
||||
body += colors.comma.open + ',' + colors.comma.close + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
body += (min ? '' : colors.comma.open + ',' + colors.comma.close) + edgeSpacing + prevIndent;
|
||||
}
|
||||
|
||||
return colors.bracket.open + '[' + colors.bracket.close + body + colors.bracket.open + ']' + colors.bracket.close;
|
||||
}
|
||||
|
||||
function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
return colors.label.open + (min ? '' : 'Arguments ') + colors.label.close + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
return colors.label.open + (min ? '' : val.constructor.name + ' ') + colors.label.close + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
function printKey(key, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
const typeOf = typeof key;
|
||||
if (typeOf === 'string') {
|
||||
if (keyword.isIdentifierNameES6(key, true)) return colors.key.open + key + colors.key.close;
|
||||
if (/^\d+$/.test(key)) return colors.key.open + key + colors.key.close;
|
||||
return colors.key.open + '"' + printString(key) + '"' + colors.key.close;
|
||||
}
|
||||
if (typeOf === 'symbol') return colors.key.open + printSymbol(key) + colors.key.close;
|
||||
|
||||
return print(key, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
let result = colors.label.open + 'Map ' + colors.label.close + colors.bracket.open + '{' + colors.bracket.close;
|
||||
const iterator = val.entries();
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += edgeSpacing;
|
||||
|
||||
const innerIndent = prevIndent + indent;
|
||||
|
||||
while (!current.done) {
|
||||
const key = printKey(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
const value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
|
||||
result += innerIndent + key + ' => ' + value;
|
||||
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += colors.comma.open + ',' + colors.comma.close + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
result += (min ? '' : colors.comma.open + ',' + colors.comma.close) + edgeSpacing + prevIndent;
|
||||
}
|
||||
|
||||
return result + colors.bracket.open + '}' + colors.bracket.close;
|
||||
}
|
||||
|
||||
function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
const constructor = min ? '' : (val.constructor ? val.constructor.name + ' ' : 'Object ');
|
||||
let result = colors.label.open + constructor + colors.label.close + colors.bracket.open + '{' + colors.bracket.close;
|
||||
let keys = Object.keys(val).sort();
|
||||
const symbols = getSymbols(val);
|
||||
|
||||
if (symbols.length) {
|
||||
keys = keys
|
||||
.filter(key => !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]'))
|
||||
.concat(symbols);
|
||||
}
|
||||
|
||||
if (keys.length) {
|
||||
result += edgeSpacing;
|
||||
|
||||
const innerIndent = prevIndent + indent;
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const name = printKey(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
const value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
|
||||
result += innerIndent + name + ': ' + value;
|
||||
|
||||
if (i < keys.length - 1) {
|
||||
result += colors.comma.open + ',' + colors.comma.close + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
result += (min ? '' : colors.comma.open + ',' + colors.comma.close) + edgeSpacing + prevIndent;
|
||||
}
|
||||
|
||||
return result + colors.bracket.open + '}' + colors.bracket.close;
|
||||
}
|
||||
|
||||
function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
let result = colors.label.open + 'Set ' + colors.label.close + colors.bracket.open + '{' + colors.bracket.close;
|
||||
const iterator = val.entries();
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += edgeSpacing;
|
||||
|
||||
const innerIndent = prevIndent + indent;
|
||||
|
||||
while (!current.done) {
|
||||
result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += colors.comma.open + ',' + colors.comma.close + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
result += (min ? '' : colors.comma.open + ',' + colors.comma.close) + edgeSpacing + prevIndent;
|
||||
}
|
||||
|
||||
return result + colors.bracket.open + '}' + colors.bracket.close;
|
||||
}
|
||||
|
||||
function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
refs = refs.slice();
|
||||
if (refs.indexOf(val) > -1) {
|
||||
return '[Circular]';
|
||||
} else {
|
||||
refs.push(val);
|
||||
}
|
||||
|
||||
currentDepth++;
|
||||
|
||||
const hitMaxDepth = currentDepth > maxDepth;
|
||||
|
||||
if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {
|
||||
return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
if (toStringed === '[object Arguments]') {
|
||||
return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
} else if (isToStringedArrayType(toStringed)) {
|
||||
return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
} else if (toStringed === '[object Map]') {
|
||||
return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
} else if (toStringed === '[object Set]') {
|
||||
return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
} else if (typeof val === 'object') {
|
||||
return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
}
|
||||
|
||||
function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
let match = false;
|
||||
let plugin;
|
||||
|
||||
for (let p = 0; p < plugins.length; p++) {
|
||||
plugin = plugins[p];
|
||||
|
||||
if (plugin.test(val)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function boundPrint(val) {
|
||||
return print(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
function boundIndent(str) {
|
||||
const indentation = prevIndent + indent;
|
||||
return indentation + str.replace(NEWLINE_REGEXP, '\n' + indentation);
|
||||
}
|
||||
|
||||
const opts = {
|
||||
edgeSpacing: edgeSpacing,
|
||||
spacing: spacing
|
||||
};
|
||||
return plugin.print(val, boundPrint, boundIndent, opts, colors);
|
||||
}
|
||||
|
||||
function print(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors) {
|
||||
const basic = printBasicValue(val, printFunctionName, escapeRegex, colors);
|
||||
if (basic) return basic;
|
||||
|
||||
const plugin = printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
if (plugin) return plugin;
|
||||
|
||||
return printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex, colors);
|
||||
}
|
||||
|
||||
const DEFAULTS = {
|
||||
callToJSON: true,
|
||||
indent: 2,
|
||||
maxDepth: Infinity,
|
||||
min: false,
|
||||
plugins: [],
|
||||
printFunctionName: true,
|
||||
escapeRegex: false,
|
||||
highlight: false,
|
||||
theme: {
|
||||
tag: 'cyan',
|
||||
content: 'reset',
|
||||
prop: 'yellow',
|
||||
value: 'green',
|
||||
number: 'yellow',
|
||||
string: 'red',
|
||||
date: 'red',
|
||||
symbol: 'red',
|
||||
regex: 'red',
|
||||
function: 'blue',
|
||||
error: 'red',
|
||||
boolean: 'yellow',
|
||||
label: 'blue',
|
||||
bracket: 'grey',
|
||||
comma: 'grey',
|
||||
misc: 'grey',
|
||||
key: 'reset'
|
||||
}
|
||||
};
|
||||
|
||||
function validateOptions(opts) {
|
||||
Object.keys(opts).forEach(key => {
|
||||
if (!DEFAULTS.hasOwnProperty(key)) {
|
||||
throw new Error('prettyFormat: Invalid option: ' + key);
|
||||
}
|
||||
});
|
||||
|
||||
if (opts.min && opts.indent !== undefined && opts.indent !== 0) {
|
||||
throw new Error('prettyFormat: Cannot run with min option and indent');
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeOptions(opts) {
|
||||
const result = {};
|
||||
|
||||
Object.keys(DEFAULTS).forEach(key =>
|
||||
result[key] = opts.hasOwnProperty(key) ? opts[key] : DEFAULTS[key]
|
||||
);
|
||||
|
||||
if (result.min) {
|
||||
result.indent = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createIndent(indent) {
|
||||
return new Array(indent + 1).join(' ');
|
||||
}
|
||||
|
||||
function prettyFormat(val, opts) {
|
||||
if (!opts) {
|
||||
opts = DEFAULTS;
|
||||
} else {
|
||||
validateOptions(opts)
|
||||
opts = normalizeOptions(opts);
|
||||
}
|
||||
|
||||
let colors = {};
|
||||
Object.keys(opts.theme).forEach(key => {
|
||||
if (opts.highlight) {
|
||||
colors[key] = style[opts.theme[key]];
|
||||
} else {
|
||||
colors[key] = {open: '', close: ''};
|
||||
}
|
||||
});
|
||||
|
||||
let indent;
|
||||
let refs;
|
||||
const prevIndent = '';
|
||||
const currentDepth = 0;
|
||||
const spacing = opts.min ? ' ' : '\n';
|
||||
const edgeSpacing = opts.min ? '' : '\n';
|
||||
|
||||
if (opts && opts.plugins.length) {
|
||||
indent = createIndent(opts.indent);
|
||||
refs = [];
|
||||
var pluginsResult = printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, opts.maxDepth, currentDepth, opts.plugins, opts.min, opts.callToJSON, opts.printFunctionName, opts.escapeRegex, colors);
|
||||
if (pluginsResult) return pluginsResult;
|
||||
}
|
||||
|
||||
var basicResult = printBasicValue(val, opts.printFunctionName, opts.escapeRegex, colors);
|
||||
if (basicResult) return basicResult;
|
||||
|
||||
if (!indent) indent = createIndent(opts.indent);
|
||||
if (!refs) refs = [];
|
||||
return printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, opts.maxDepth, currentDepth, opts.plugins, opts.min, opts.callToJSON, opts.printFunctionName, opts.escapeRegex, colors);
|
||||
}
|
||||
|
||||
module.exports = prettyFormat;
|
29
node_modules/@ava/pretty-format/package.json
generated
vendored
Normal file
29
node_modules/@ava/pretty-format/package.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@ava/pretty-format",
|
||||
"version": "1.1.0",
|
||||
"description": "Stringify any JavaScript value",
|
||||
"license": "MIT",
|
||||
"repository": "avajs/pretty-format",
|
||||
"author": "James Kyle <me@thejameskyle.com>",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"perf": "node perf/test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"esutils": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chalk": "^1.1.3",
|
||||
"jest": "^15.1.1",
|
||||
"left-pad": "^1.1.1",
|
||||
"react": "15.3.0"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"verbose": true
|
||||
}
|
||||
}
|
83
node_modules/@ava/pretty-format/plugins/ReactElement.js
generated
vendored
Normal file
83
node_modules/@ava/pretty-format/plugins/ReactElement.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
|
||||
const printString = require('../printString');
|
||||
|
||||
const reactElement = Symbol.for('react.element');
|
||||
|
||||
function traverseChildren(opaqueChildren, cb) {
|
||||
if (Array.isArray(opaqueChildren)) {
|
||||
opaqueChildren.forEach(child => traverseChildren(child, cb));
|
||||
} else if (opaqueChildren != null && opaqueChildren !== false) {
|
||||
cb(opaqueChildren);
|
||||
}
|
||||
}
|
||||
|
||||
function printChildren(flatChildren, print, indent, colors, opts) {
|
||||
return flatChildren.map(node => {
|
||||
if (typeof node === 'object') {
|
||||
return printElement(node, print, indent, colors, opts);
|
||||
} else if (typeof node === 'string') {
|
||||
return printString(colors.content.open + node + colors.content.close);
|
||||
} else {
|
||||
return print(node);
|
||||
}
|
||||
}).join(opts.edgeSpacing);
|
||||
}
|
||||
|
||||
function printProps(props, print, indent, colors, opts) {
|
||||
return Object.keys(props).sort().map(name => {
|
||||
if (name === 'children') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const prop = props[name];
|
||||
let printed = print(prop);
|
||||
|
||||
if (typeof prop !== 'string') {
|
||||
if (printed.indexOf('\n') !== -1) {
|
||||
printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
|
||||
} else {
|
||||
printed = '{' + printed + '}';
|
||||
}
|
||||
}
|
||||
|
||||
return opts.spacing + indent(colors.prop.open + name + colors.prop.close + '=') + colors.value.open + printed + colors.value.close;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function printElement(element, print, indent, colors, opts) {
|
||||
let result = colors.tag.open + '<';
|
||||
let elementName;
|
||||
if (typeof element.type === 'string') {
|
||||
elementName = element.type;
|
||||
} else if (typeof element.type === 'function') {
|
||||
elementName = element.type.displayName || element.type.name || 'Unknown';
|
||||
} else {
|
||||
elementName = 'Unknown';
|
||||
}
|
||||
result += elementName + colors.tag.close;
|
||||
result += printProps(element.props, print, indent, colors, opts);
|
||||
|
||||
const opaqueChildren = element.props.children;
|
||||
if (opaqueChildren) {
|
||||
let flatChildren = [];
|
||||
traverseChildren(opaqueChildren, child => {
|
||||
flatChildren.push(child);
|
||||
});
|
||||
const children = printChildren(flatChildren, print, indent, colors, opts);
|
||||
result += colors.tag.open + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + elementName + '>' + colors.tag.close;
|
||||
} else {
|
||||
result += colors.tag.open + ' />' + colors.tag.close;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
test(object) {
|
||||
return object && object.$$typeof === reactElement;
|
||||
},
|
||||
print(val, print, indent, opts, colors) {
|
||||
return printElement(val, print, indent, colors, opts);
|
||||
}
|
||||
};
|
58
node_modules/@ava/pretty-format/plugins/ReactTestComponent.js
generated
vendored
Normal file
58
node_modules/@ava/pretty-format/plugins/ReactTestComponent.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
const printString = require('../printString');
|
||||
|
||||
const reactTestInstance = Symbol.for('react.test.json');
|
||||
|
||||
function printChildren(children, print, indent, colors, opts) {
|
||||
return children.map(child => printInstance(child, print, indent, colors, opts)).join(opts.edgeSpacing);
|
||||
}
|
||||
|
||||
function printProps(props, print, indent, colors, opts) {
|
||||
return Object.keys(props).sort().map(name => {
|
||||
const prop = props[name];
|
||||
let printed = print(prop);
|
||||
|
||||
if (typeof prop !== 'string') {
|
||||
if (printed.indexOf('\n') !== -1) {
|
||||
printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
|
||||
} else {
|
||||
printed = '{' + printed + '}';
|
||||
}
|
||||
}
|
||||
|
||||
return opts.spacing + indent(colors.prop.open + name + colors.prop.close + '=') + colors.value.open + printed + colors.value.close;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function printInstance(instance, print, indent, colors, opts) {
|
||||
if (typeof instance == 'number') {
|
||||
return print(instance);
|
||||
} else if (typeof instance === 'string') {
|
||||
return printString(colors.content.open + instance + colors.content.close);
|
||||
}
|
||||
|
||||
let result = colors.tag.open + '<' + instance.type + colors.tag.close;
|
||||
|
||||
if (instance.props) {
|
||||
result += printProps(instance.props, print, indent, colors, opts);
|
||||
}
|
||||
|
||||
if (instance.children) {
|
||||
const children = printChildren(instance.children, print, indent, colors, opts);
|
||||
result += colors.tag.open + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + instance.type + '>' + colors.tag.close;
|
||||
} else {
|
||||
result += colors.tag.open + ' />' + colors.tag.close;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
test(object) {
|
||||
return object && object.$$typeof === reactTestInstance;
|
||||
},
|
||||
print(val, print, indent, opts, colors) {
|
||||
return printInstance(val, print, indent, colors, opts);
|
||||
}
|
||||
};
|
7
node_modules/@ava/pretty-format/printString.js
generated
vendored
Normal file
7
node_modules/@ava/pretty-format/printString.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const ESCAPED_CHARACTERS = /(\\|\"|\')/g;
|
||||
|
||||
module.exports = function printString(val) {
|
||||
return val.replace(ESCAPED_CHARACTERS, '\\$1');
|
||||
}
|
36
node_modules/ansi-align/CHANGELOG.md
generated
vendored
Normal file
36
node_modules/ansi-align/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
# 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="2.0.0"></a>
|
||||
# [2.0.0](https://github.com/nexdrew/ansi-align/compare/v1.1.0...v2.0.0) (2017-05-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ES2015ify, dropping support for Node <4 ([#30](https://github.com/nexdrew/ansi-align/issues/30)) ([7b43f48](https://github.com/nexdrew/ansi-align/commit/7b43f48))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Node 0.10 or 0.12 no longer supported, please update to Node 4+ or use ansi-align@1.1.0
|
||||
|
||||
|
||||
|
||||
<a name="1.1.0"></a>
|
||||
# [1.1.0](https://github.com/nexdrew/ansi-align/compare/v1.0.0...v1.1.0) (2016-06-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support left-alignment as no-op ([#3](https://github.com/nexdrew/ansi-align/issues/3)) ([e581db6](https://github.com/nexdrew/ansi-align/commit/e581db6))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# 1.0.0 (2016-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* initial commit ([1914d90](https://github.com/nexdrew/ansi-align/commit/1914d90))
|
13
node_modules/ansi-align/LICENSE
generated
vendored
Normal file
13
node_modules/ansi-align/LICENSE
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright (c) 2016, 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.
|
79
node_modules/ansi-align/README.md
generated
vendored
Normal file
79
node_modules/ansi-align/README.md
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
# ansi-align
|
||||
|
||||
> align-text with ANSI support for CLIs
|
||||
|
||||
[![Build Status](https://travis-ci.org/nexdrew/ansi-align.svg?branch=master)](https://travis-ci.org/nexdrew/ansi-align)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/nexdrew/ansi-align/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/ansi-align?branch=master)
|
||||
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
|
||||
|
||||
Easily center- or right- align a block of text, carefully ignoring ANSI escape codes.
|
||||
|
||||
E.g. turn this:
|
||||
|
||||
<img width="281" alt="ansi text block no alignment :(" src="https://cloud.githubusercontent.com/assets/1929625/14937509/7c3076dc-0ed7-11e6-8c16-4f6a4ccc8346.png">
|
||||
|
||||
Into this:
|
||||
|
||||
<img width="278" alt="ansi text block center aligned!" src="https://cloud.githubusercontent.com/assets/1929625/14937510/7c3ca0b0-0ed7-11e6-8f0a-541ca39b6e0a.png">
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save ansi-align
|
||||
```
|
||||
|
||||
```js
|
||||
var ansiAlign = require('ansi-align')
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `ansiAlign(text, [opts])`
|
||||
|
||||
Align the given text per the line with the greatest [`string-width`](https://github.com/sindresorhus/string-width), returning a new string (or array).
|
||||
|
||||
#### Arguments
|
||||
|
||||
- `text`: required, string or array
|
||||
|
||||
The text to align. If a string is given, it will be split using either the `opts.split` value or `'\n'` by default. If an array is given, a different array of modified strings will be returned.
|
||||
|
||||
- `opts`: optional, object
|
||||
|
||||
Options to change behavior, see below.
|
||||
|
||||
#### Options
|
||||
|
||||
- `opts.align`: string, default `'center'`
|
||||
|
||||
The alignment mode. Use `'center'` for center-alignment, `'right'` for right-alignment, or `'left'` for left-alignment. Note that the given `text` is assumed to be left-aligned already, so specifying `align: 'left'` just returns the `text` as is (no-op).
|
||||
|
||||
- `opts.split`: string or RegExp, default `'\n'`
|
||||
|
||||
The separator to use when splitting the text. Only used if text is given as a string.
|
||||
|
||||
- `opts.pad`: string, default `' '`
|
||||
|
||||
The value used to left-pad (prepend to) lines of lesser width. Will be repeated as necessary to adjust alignment to the line with the greatest width.
|
||||
|
||||
### `ansiAlign.center(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'center' })`.
|
||||
|
||||
### `ansiAlign.right(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'right' })`.
|
||||
|
||||
### `ansiAlign.left(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'left' })`, which is a no-op.
|
||||
|
||||
## Similar Packages
|
||||
|
||||
- [`center-align`](https://github.com/jonschlinkert/center-align): Very close to this package, except it doesn't support ANSI codes.
|
||||
- [`left-pad`](https://github.com/camwest/left-pad): Great for left-padding but does not support center alignment or ANSI codes.
|
||||
- Pretty much anything by the [chalk](https://github.com/chalk) team
|
||||
|
||||
## License
|
||||
|
||||
ISC © Contributors
|
61
node_modules/ansi-align/index.js
generated
vendored
Normal file
61
node_modules/ansi-align/index.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
|
||||
const stringWidth = require('string-width')
|
||||
|
||||
function ansiAlign (text, opts) {
|
||||
if (!text) return text
|
||||
|
||||
opts = opts || {}
|
||||
const align = opts.align || 'center'
|
||||
|
||||
// short-circuit `align: 'left'` as no-op
|
||||
if (align === 'left') return text
|
||||
|
||||
const split = opts.split || '\n'
|
||||
const pad = opts.pad || ' '
|
||||
const widthDiffFn = align !== 'right' ? halfDiff : fullDiff
|
||||
|
||||
let returnString = false
|
||||
if (!Array.isArray(text)) {
|
||||
returnString = true
|
||||
text = String(text).split(split)
|
||||
}
|
||||
|
||||
let width
|
||||
let maxWidth = 0
|
||||
text = text.map(function (str) {
|
||||
str = String(str)
|
||||
width = stringWidth(str)
|
||||
maxWidth = Math.max(width, maxWidth)
|
||||
return {
|
||||
str,
|
||||
width
|
||||
}
|
||||
}).map(function (obj) {
|
||||
return new Array(widthDiffFn(maxWidth, obj.width) + 1).join(pad) + obj.str
|
||||
})
|
||||
|
||||
return returnString ? text.join(split) : text
|
||||
}
|
||||
|
||||
ansiAlign.left = function left (text) {
|
||||
return ansiAlign(text, { align: 'left' })
|
||||
}
|
||||
|
||||
ansiAlign.center = function center (text) {
|
||||
return ansiAlign(text, { align: 'center' })
|
||||
}
|
||||
|
||||
ansiAlign.right = function right (text) {
|
||||
return ansiAlign(text, { align: 'right' })
|
||||
}
|
||||
|
||||
module.exports = ansiAlign
|
||||
|
||||
function halfDiff (maxWidth, curWidth) {
|
||||
return Math.floor((maxWidth - curWidth) / 2)
|
||||
}
|
||||
|
||||
function fullDiff (maxWidth, curWidth) {
|
||||
return maxWidth - curWidth
|
||||
}
|
46
node_modules/ansi-align/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
46
node_modules/ansi-align/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
/* eslint-disable yoda */
|
||||
module.exports = x => {
|
||||
if (Number.isNaN(x)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// code points are derived from:
|
||||
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
|
||||
if (
|
||||
x >= 0x1100 && (
|
||||
x <= 0x115f || // Hangul Jamo
|
||||
x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
|
||||
x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
|
||||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
||||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
|
||||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
||||
(0x3250 <= x && x <= 0x4dbf) ||
|
||||
// CJK Unified Ideographs .. Yi Radicals
|
||||
(0x4e00 <= x && x <= 0xa4c6) ||
|
||||
// Hangul Jamo Extended-A
|
||||
(0xa960 <= x && x <= 0xa97c) ||
|
||||
// Hangul Syllables
|
||||
(0xac00 <= x && x <= 0xd7a3) ||
|
||||
// CJK Compatibility Ideographs
|
||||
(0xf900 <= x && x <= 0xfaff) ||
|
||||
// Vertical Forms
|
||||
(0xfe10 <= x && x <= 0xfe19) ||
|
||||
// CJK Compatibility Forms .. Small Form Variants
|
||||
(0xfe30 <= x && x <= 0xfe6b) ||
|
||||
// Halfwidth and Fullwidth Forms
|
||||
(0xff01 <= x && x <= 0xff60) ||
|
||||
(0xffe0 <= x && x <= 0xffe6) ||
|
||||
// Kana Supplement
|
||||
(0x1b000 <= x && x <= 0x1b001) ||
|
||||
// Enclosed Ideographic Supplement
|
||||
(0x1f200 <= x && x <= 0x1f251) ||
|
||||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
||||
(0x20000 <= x && x <= 0x3fffd)
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
21
node_modules/ansi-align/node_modules/is-fullwidth-code-point/license
generated
vendored
Normal file
21
node_modules/ansi-align/node_modules/is-fullwidth-code-point/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/ansi-align/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
45
node_modules/ansi-align/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "is-fullwidth-code-point",
|
||||
"version": "2.0.0",
|
||||
"description": "Check if the character represented by a given Unicode code point is fullwidth",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-fullwidth-code-point",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"full",
|
||||
"width",
|
||||
"unicode",
|
||||
"character",
|
||||
"char",
|
||||
"string",
|
||||
"str",
|
||||
"codepoint",
|
||||
"code",
|
||||
"point",
|
||||
"is",
|
||||
"detect",
|
||||
"check"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
39
node_modules/ansi-align/node_modules/is-fullwidth-code-point/readme.md
generated
vendored
Normal file
39
node_modules/ansi-align/node_modules/is-fullwidth-code-point/readme.md
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point)
|
||||
|
||||
> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save is-fullwidth-code-point
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
|
||||
isFullwidthCodePoint('谢'.codePointAt());
|
||||
//=> true
|
||||
|
||||
isFullwidthCodePoint('a'.codePointAt());
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### isFullwidthCodePoint(input)
|
||||
|
||||
#### input
|
||||
|
||||
Type: `number`
|
||||
|
||||
[Code point](https://en.wikipedia.org/wiki/Code_point) of a character.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
35
node_modules/ansi-align/node_modules/string-width/index.js
generated
vendored
Normal file
35
node_modules/ansi-align/node_modules/string-width/index.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
|
||||
module.exports = str => {
|
||||
if (typeof str !== 'string' || str.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let width = 0;
|
||||
|
||||
str = stripAnsi(str);
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const code = str.codePointAt(i);
|
||||
|
||||
// ignore control characters
|
||||
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// surrogates
|
||||
if (code >= 0x10000) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (isFullwidthCodePoint(code)) {
|
||||
width += 2;
|
||||
} else {
|
||||
width++;
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
};
|
21
node_modules/ansi-align/node_modules/string-width/license
generated
vendored
Normal file
21
node_modules/ansi-align/node_modules/string-width/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.
|
58
node_modules/ansi-align/node_modules/string-width/package.json
generated
vendored
Normal file
58
node_modules/ansi-align/node_modules/string-width/package.json
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "string-width",
|
||||
"version": "2.0.0",
|
||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/string-width",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"string",
|
||||
"str",
|
||||
"character",
|
||||
"char",
|
||||
"unicode",
|
||||
"width",
|
||||
"visual",
|
||||
"column",
|
||||
"columns",
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"full",
|
||||
"ansi",
|
||||
"escape",
|
||||
"codes",
|
||||
"cli",
|
||||
"command-line",
|
||||
"terminal",
|
||||
"console",
|
||||
"cjk",
|
||||
"chinese",
|
||||
"japanese",
|
||||
"korean",
|
||||
"fixed-width"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
42
node_modules/ansi-align/node_modules/string-width/readme.md
generated
vendored
Normal file
42
node_modules/ansi-align/node_modules/string-width/readme.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width)
|
||||
|
||||
> Get the visual width of a string - the number of columns required to display it
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
Useful to be able to measure the actual width of command-line output.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save string-width
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stringWidth = require('string-width');
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001b[1m古\u001b[22m');
|
||||
//=> 2
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
43
node_modules/ansi-align/package.json
generated
vendored
Normal file
43
node_modules/ansi-align/package.json
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "ansi-align",
|
||||
"version": "2.0.0",
|
||||
"description": "align-text with ANSI support for CLIs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"pretest": "standard",
|
||||
"test": "nyc ava",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nexdrew/ansi-align.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"align",
|
||||
"cli",
|
||||
"center",
|
||||
"pad"
|
||||
],
|
||||
"author": "nexdrew",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nexdrew/ansi-align/issues"
|
||||
},
|
||||
"homepage": "https://github.com/nexdrew/ansi-align#readme",
|
||||
"dependencies": {
|
||||
"string-width": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.19.1",
|
||||
"chalk": "^1.1.3",
|
||||
"coveralls": "^2.13.1",
|
||||
"nyc": "^10.3.0",
|
||||
"standard": "^10.0.2",
|
||||
"standard-version": "^4.0.0"
|
||||
}
|
||||
}
|
88
node_modules/append-transform/index.js
generated
vendored
Normal file
88
node_modules/append-transform/index.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
var js = require('default-require-extensions/js');
|
||||
|
||||
module.exports = appendTransform;
|
||||
|
||||
var count = 0;
|
||||
|
||||
function appendTransform(transform, ext, extensions) {
|
||||
// Generate a unique key for this transform
|
||||
var key = __dirname + count; // eslint-disable-line
|
||||
count++;
|
||||
ext = ext || '.js';
|
||||
extensions = extensions || require.extensions;
|
||||
|
||||
var forwardGet;
|
||||
var forwardSet;
|
||||
|
||||
var descriptor = Object.getOwnPropertyDescriptor(extensions, ext) || {value: js, configurable: true};
|
||||
|
||||
if (
|
||||
((descriptor.get || descriptor.set) && !(descriptor.get && descriptor.set)) ||
|
||||
!descriptor.configurable
|
||||
) {
|
||||
throw new Error('Somebody did bad things to require.extensions["' + ext + '"]');
|
||||
}
|
||||
|
||||
if (descriptor.get) {
|
||||
// wrap a previous append-transform install and pass through to the getter/setter pair it created
|
||||
forwardGet = function () {
|
||||
return descriptor.get();
|
||||
};
|
||||
forwardSet = function (val) {
|
||||
descriptor.set(val);
|
||||
return forwardGet();
|
||||
};
|
||||
} else {
|
||||
forwardGet = function () {
|
||||
return descriptor.value;
|
||||
};
|
||||
forwardSet = function (val) {
|
||||
descriptor.value = val;
|
||||
return val;
|
||||
};
|
||||
}
|
||||
|
||||
function wrapCustomHook(hook) {
|
||||
return function (module, filename) {
|
||||
// We wrap every added extension, but we only apply the transform to the one on top of the stack
|
||||
if (!module[key]) {
|
||||
module[key] = true;
|
||||
|
||||
var originalCompile = module._compile;
|
||||
|
||||
module._compile = function replacementCompile(code, filename) {
|
||||
module._compile = originalCompile;
|
||||
code = transform(code, filename);
|
||||
module._compile(code, filename);
|
||||
};
|
||||
}
|
||||
|
||||
hook(module, filename);
|
||||
};
|
||||
}
|
||||
|
||||
// wrap the original
|
||||
forwardSet(wrapCustomHook(forwardGet()));
|
||||
|
||||
var hooks = [forwardGet()];
|
||||
|
||||
function setCurrentHook(hook) {
|
||||
var restoreIndex = hooks.indexOf(hook);
|
||||
if (restoreIndex === -1) {
|
||||
hooks.push(forwardSet(wrapCustomHook(hook)));
|
||||
} else {
|
||||
// we have already scene this hook, and it is being reverted (proxyquire, etc) - don't wrap again.
|
||||
hooks.splice(restoreIndex + 1, hooks.length);
|
||||
forwardSet(hook);
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(extensions, ext, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: forwardGet,
|
||||
set: setCurrentHook
|
||||
});
|
||||
}
|
21
node_modules/append-transform/license
generated
vendored
Normal file
21
node_modules/append-transform/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
|
||||
|
||||
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/append-transform/package.json
generated
vendored
Normal file
46
node_modules/append-transform/package.json
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "append-transform",
|
||||
"version": "0.4.0",
|
||||
"description": "Install a transform to `require.extensions` that always runs last, even if additional extensions are added later.",
|
||||
"license": "MIT",
|
||||
"repository": "jamestalmage/append-transform",
|
||||
"author": {
|
||||
"name": "James Talmage",
|
||||
"email": "james@talmage.io",
|
||||
"url": "github.com/jamestalmage"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc --reporter=lcov --reporter=text ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"transform",
|
||||
"require",
|
||||
"append",
|
||||
"last",
|
||||
"coverage",
|
||||
"source-map",
|
||||
"extension",
|
||||
"module"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^0.7.0",
|
||||
"coveralls": "^2.11.6",
|
||||
"fake-module-system": "^0.3.0",
|
||||
"nyc": "^4.0.1",
|
||||
"xo": "^0.11.2"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"test.js"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"default-require-extensions": "^1.0.0"
|
||||
}
|
||||
}
|
72
node_modules/append-transform/readme.md
generated
vendored
Normal file
72
node_modules/append-transform/readme.md
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# append-transform [![Build Status](https://travis-ci.org/jamestalmage/append-transform.svg?branch=master)](https://travis-ci.org/jamestalmage/append-transform) [![Coverage Status](https://coveralls.io/repos/jamestalmage/append-transform/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamestalmage/append-transform?branch=master)
|
||||
|
||||
> Install a transform to `require.extensions` that always runs last, even if additional extensions are added later.
|
||||
|
||||
The [typical require extension](https://gist.github.com/jamestalmage/df922691475cff66c7e6) looks something like this:
|
||||
|
||||
```js
|
||||
var myTransform = require('my-transform');
|
||||
|
||||
var oldExtension = require.extensions['.js'];
|
||||
require.extensions['.js'] = function (module, filename) {
|
||||
var oldCompile = module._compile;
|
||||
module._compile = function (code, filename) {
|
||||
code = myTransform(code);
|
||||
module._compile = oldCompile;
|
||||
module._compile(code, filename);
|
||||
};
|
||||
oldExtension(module, filename);
|
||||
};
|
||||
```
|
||||
|
||||
In **almost** all cases, that is sufficient and is the method that should be used (check out [`pirates`](https://www.npmjs.com/package/pirates) for an easy way to do it correctly). In **rare** cases you must ensure your transform remains the last one, even if other transforms are added later. For example, `nyc` uses this module to ensure its transform is applied last so it can capture the final source-map information, and ensure any language extensions it can't understand are already transpiled (ES2015 via `babel` for instance).
|
||||
|
||||
*WARNING:* You should be sure you *actually* need this, as it takes control away from the user. Your transform remains the last one applied, even as users continue to add more transforms. This is potentially confusing. Coverage libraries like `nyc` (and `istanbul` on which it relies) have valid reasons for doing this, but you should prefer conventional transform installation via [`pirates`](https://www.npmjs.com/package/pirates).
|
||||
|
||||
References:
|
||||
- [Detailed Breakdown of How Require Extensions Work](https://gist.github.com/jamestalmage/df922691475cff66c7e6)
|
||||
- The [test suite](https://github.com/jamestalmage/append-transform/blob/master/test/execution-order.js) provides a good overview of how this library manipulates the order in which transforms are applied.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save append-transform
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var appendTransform = require('append-transform');
|
||||
var myTransform = require('my-transform');
|
||||
|
||||
appendTransform(function (code, filename) {
|
||||
if (myTransform.shouldTransform(filename)) {
|
||||
code = myTransform.transform(code);
|
||||
}
|
||||
return code;
|
||||
});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### appendTransform(transformFn, [extension])
|
||||
|
||||
#### transformFn
|
||||
|
||||
Type: `function(code: string, filename: string)`
|
||||
*Required*
|
||||
|
||||
A callback that modifies the incoming `code` argument in some way, and returns the transformed result. `filename` is provided to filter which files the transform applies to. If a transform should not manipulate a particular file, just return `code` without modifying it. It is fairly common to avoid transforming files in `node_modules`. In that case you may want to use [`node-modules-regexp`](https://www.npmjs.com/package/node-modules-regexp) to help reliably detect `node_modules` paths and avoid transforming them.
|
||||
|
||||
|
||||
#### extension
|
||||
|
||||
Type: `string`
|
||||
Default: `".js"`
|
||||
|
||||
The extension for the types of files this transform is capable of handling.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [James Talmage](http://github.com/jamestalmage)
|
10
node_modules/arr-exclude/index.js
generated
vendored
Normal file
10
node_modules/arr-exclude/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
module.exports = function (input, exclude) {
|
||||
if (!Array.isArray(input)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return input.filter(function (x) {
|
||||
return exclude.indexOf(x) === -1;
|
||||
});
|
||||
};
|
21
node_modules/arr-exclude/license
generated
vendored
Normal file
21
node_modules/arr-exclude/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/arr-exclude/package.json
generated
vendored
Normal file
38
node_modules/arr-exclude/package.json
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "arr-exclude",
|
||||
"version": "1.0.0",
|
||||
"description": "Exclude certain items from an array",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/arr-exclude",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"array",
|
||||
"arr",
|
||||
"list",
|
||||
"exclude",
|
||||
"blacklist",
|
||||
"ignore",
|
||||
"without",
|
||||
"items",
|
||||
"elements",
|
||||
"values",
|
||||
"filter"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
30
node_modules/arr-exclude/readme.md
generated
vendored
Normal file
30
node_modules/arr-exclude/readme.md
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
# arr-exclude [![Build Status](https://travis-ci.org/sindresorhus/arr-exclude.svg?branch=master)](https://travis-ci.org/sindresorhus/arr-exclude)
|
||||
|
||||
> Exclude certain items from an array
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save arr-exclude
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var arrExclude = require('arr-exclude');
|
||||
|
||||
arrExclude(['a', 'b', 'c'], ['b']);
|
||||
//=> ['a', 'c']
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [arr-include](https://github.com/sindresorhus/arr-include) - Include only certain items in an array
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
12
node_modules/auto-bind/index.js
generated
vendored
Normal file
12
node_modules/auto-bind/index.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
module.exports = self => {
|
||||
for (const key of Object.getOwnPropertyNames(self.constructor.prototype)) {
|
||||
const val = self[key];
|
||||
|
||||
if (key !== 'constructor' && typeof val === 'function') {
|
||||
self[key] = val.bind(self);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
21
node_modules/auto-bind/license
generated
vendored
Normal file
21
node_modules/auto-bind/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/auto-bind/package.json
generated
vendored
Normal file
38
node_modules/auto-bind/package.json
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "auto-bind",
|
||||
"version": "1.1.0",
|
||||
"description": "Automatically bind methods to their class instance",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/auto-bind",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"auto",
|
||||
"bind",
|
||||
"class",
|
||||
"methods",
|
||||
"method",
|
||||
"automatically",
|
||||
"prototype",
|
||||
"instance",
|
||||
"function",
|
||||
"this",
|
||||
"self"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
63
node_modules/auto-bind/readme.md
generated
vendored
Normal file
63
node_modules/auto-bind/readme.md
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# auto-bind [![Build Status](https://travis-ci.org/sindresorhus/auto-bind.svg?branch=master)](https://travis-ci.org/sindresorhus/auto-bind)
|
||||
|
||||
> Automatically bind methods to their class instance
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save auto-bind
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const autoBind = require('auto-bind');
|
||||
|
||||
class Unicorn {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
autoBind(this);
|
||||
}
|
||||
message() {
|
||||
return `${this.name} is awesome!`;
|
||||
}
|
||||
}
|
||||
|
||||
const unicorn = new Unicorn('Rainbow');
|
||||
|
||||
// Grab the method off the class instance
|
||||
const message = unicorn.message;
|
||||
|
||||
// Still bound to the class instance
|
||||
message();
|
||||
//=> 'Rainbow is awesome!'
|
||||
|
||||
// Without `autoBind(this)`, the above would have resulted in
|
||||
message();
|
||||
//=> Error: Cannot read property 'name' of undefined
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### autoBind(self)
|
||||
|
||||
Bind methods in `self` to their class instance. Returns the `self` object.
|
||||
|
||||
#### self
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Object with methods to bind.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [bind-methods](https://github.com/sindresorhus/bind-methods) - Bind all methods in an object to itself or a specified context
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
60
node_modules/ava-init/index.js
generated
vendored
Normal file
60
node_modules/ava-init/index.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const execa = require('execa');
|
||||
const hasYarn = require('has-yarn');
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
const writePkg = require('write-pkg');
|
||||
const arrExclude = require('arr-exclude');
|
||||
|
||||
const DEFAULT_TEST_SCRIPT = 'echo "Error: no test specified" && exit 1';
|
||||
|
||||
module.exports = opts => {
|
||||
opts = opts || {};
|
||||
|
||||
const ret = readPkgUp.sync({
|
||||
cwd: opts.cwd,
|
||||
normalize: false
|
||||
});
|
||||
const pkg = ret.pkg || {};
|
||||
const pkgPath = ret.path || path.resolve(opts.cwd || process.cwd(), 'package.json');
|
||||
const pkgCwd = path.dirname(pkgPath);
|
||||
const cli = opts.args || process.argv.slice(2);
|
||||
const args = arrExclude(cli, ['--init', '--unicorn']);
|
||||
const cmd = 'ava' + (args.length > 0 ? ' ' + args.join(' ') : '');
|
||||
const s = pkg.scripts = pkg.scripts ? pkg.scripts : {};
|
||||
|
||||
if (s.test && s.test !== DEFAULT_TEST_SCRIPT) {
|
||||
s.test = s.test.replace(/\bnode (test\/)?test\.js\b/, cmd);
|
||||
|
||||
if (!/\bava\b/.test(s.test)) {
|
||||
s.test += ` && ${cmd}`;
|
||||
}
|
||||
} else {
|
||||
s.test = cmd;
|
||||
}
|
||||
|
||||
writePkg.sync(pkgPath, pkg);
|
||||
|
||||
const post = () => {
|
||||
// For personal use
|
||||
if (cli.indexOf('--unicorn') !== -1) {
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
pkg.devDependencies.ava = '*';
|
||||
writePkg.sync(pkgPath, pkg);
|
||||
}
|
||||
};
|
||||
|
||||
if (opts.skipInstall) {
|
||||
return Promise.resolve(post);
|
||||
}
|
||||
|
||||
if (hasYarn(pkgCwd)) {
|
||||
return execa('yarn', ['add', '--dev', 'ava'], {cwd: pkgCwd}).then(post);
|
||||
}
|
||||
|
||||
return execa('npm', ['install', '--save-dev', 'ava'], {
|
||||
cwd: pkgCwd,
|
||||
stdio: 'inherit'
|
||||
}).then(post);
|
||||
};
|
21
node_modules/ava-init/license
generated
vendored
Normal file
21
node_modules/ava-init/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.
|
48
node_modules/ava-init/node_modules/find-up/index.js
generated
vendored
Normal file
48
node_modules/ava-init/node_modules/find-up/index.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const locatePath = require('locate-path');
|
||||
|
||||
module.exports = (filename, opts) => {
|
||||
opts = opts || {};
|
||||
|
||||
const startDir = path.resolve(opts.cwd || '');
|
||||
const root = path.parse(startDir).root;
|
||||
|
||||
const filenames = [].concat(filename);
|
||||
|
||||
return new Promise(resolve => {
|
||||
(function find(dir) {
|
||||
locatePath(filenames, {cwd: dir}).then(file => {
|
||||
if (file) {
|
||||
resolve(path.join(dir, file));
|
||||
} else if (dir === root) {
|
||||
resolve(null);
|
||||
} else {
|
||||
find(path.dirname(dir));
|
||||
}
|
||||
});
|
||||
})(startDir);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = (filename, opts) => {
|
||||
opts = opts || {};
|
||||
|
||||
let dir = path.resolve(opts.cwd || '');
|
||||
const root = path.parse(dir).root;
|
||||
|
||||
const filenames = [].concat(filename);
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const file = locatePath.sync(filenames, {cwd: dir});
|
||||
|
||||
if (file) {
|
||||
return path.join(dir, file);
|
||||
} else if (dir === root) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dir = path.dirname(dir);
|
||||
}
|
||||
};
|
21
node_modules/ava-init/node_modules/find-up/license
generated
vendored
Normal file
21
node_modules/ava-init/node_modules/find-up/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.
|
53
node_modules/ava-init/node_modules/find-up/package.json
generated
vendored
Normal file
53
node_modules/ava-init/node_modules/find-up/package.json
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "find-up",
|
||||
"version": "2.1.0",
|
||||
"description": "Find a file by walking up parent directories",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/find-up",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"package",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"dir",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"locate-path": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"tempfile": "^1.1.1",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
85
node_modules/ava-init/node_modules/find-up/readme.md
generated
vendored
Normal file
85
node_modules/ava-init/node_modules/find-up/readme.md
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
# find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
|
||||
|
||||
> Find a file by walking up parent directories
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save find-up
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/
|
||||
└── Users
|
||||
└── sindresorhus
|
||||
├── unicorn.png
|
||||
└── foo
|
||||
└── bar
|
||||
├── baz
|
||||
└── example.js
|
||||
```
|
||||
|
||||
```js
|
||||
// example.js
|
||||
const findUp = require('find-up');
|
||||
|
||||
findUp('unicorn.png').then(filepath => {
|
||||
console.log(filepath);
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
});
|
||||
|
||||
findUp(['rainbow.png', 'unicorn.png']).then(filepath => {
|
||||
console.log(filepath);
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### findUp(filename, [options])
|
||||
|
||||
Returns a `Promise` for the filepath or `null`.
|
||||
|
||||
### findUp([filenameA, filenameB], [options])
|
||||
|
||||
Returns a `Promise` for the first filepath found (by respecting the order) or `null`.
|
||||
|
||||
### findUp.sync(filename, [options])
|
||||
|
||||
Returns a filepath or `null`.
|
||||
|
||||
### findUp.sync([filenameA, filenameB], [options])
|
||||
|
||||
Returns the first filepath found (by respecting the order) or `null`.
|
||||
|
||||
#### filename
|
||||
|
||||
Type: `string`
|
||||
|
||||
Filename of the file to find.
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
26
node_modules/ava-init/node_modules/path-type/index.js
generated
vendored
Normal file
26
node_modules/ava-init/node_modules/path-type/index.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const pify = require('pify');
|
||||
|
||||
function type(fn, fn2, fp) {
|
||||
if (typeof fp !== 'string') {
|
||||
return Promise.reject(new TypeError(`Expected a string, got ${typeof fp}`));
|
||||
}
|
||||
|
||||
return pify(fs[fn])(fp).then(stats => stats[fn2]());
|
||||
}
|
||||
|
||||
function typeSync(fn, fn2, fp) {
|
||||
if (typeof fp !== 'string') {
|
||||
throw new TypeError(`Expected a string, got ${typeof fp}`);
|
||||
}
|
||||
|
||||
return fs[fn](fp)[fn2]();
|
||||
}
|
||||
|
||||
exports.file = type.bind(null, 'stat', 'isFile');
|
||||
exports.dir = type.bind(null, 'stat', 'isDirectory');
|
||||
exports.symlink = type.bind(null, 'lstat', 'isSymbolicLink');
|
||||
exports.fileSync = typeSync.bind(null, 'statSync', 'isFile');
|
||||
exports.dirSync = typeSync.bind(null, 'statSync', 'isDirectory');
|
||||
exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink');
|
21
node_modules/ava-init/node_modules/path-type/license
generated
vendored
Normal file
21
node_modules/ava-init/node_modules/path-type/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.
|
48
node_modules/ava-init/node_modules/path-type/package.json
generated
vendored
Normal file
48
node_modules/ava-init/node_modules/path-type/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "path-type",
|
||||
"version": "2.0.0",
|
||||
"description": "Check if a path is a file, directory, or symlink",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/path-type",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"path",
|
||||
"fs",
|
||||
"type",
|
||||
"is",
|
||||
"check",
|
||||
"directory",
|
||||
"dir",
|
||||
"file",
|
||||
"filepath",
|
||||
"symlink",
|
||||
"symbolic",
|
||||
"link",
|
||||
"stat",
|
||||
"stats",
|
||||
"filesystem"
|
||||
],
|
||||
"dependencies": {
|
||||
"pify": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
42
node_modules/ava-init/node_modules/path-type/readme.md
generated
vendored
Normal file
42
node_modules/ava-init/node_modules/path-type/readme.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# path-type [![Build Status](https://travis-ci.org/sindresorhus/path-type.svg?branch=master)](https://travis-ci.org/sindresorhus/path-type)
|
||||
|
||||
> Check if a path is a file, directory, or symlink
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-type
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const pathType = require('path-type');
|
||||
|
||||
pathType.file('package.json').then(isFile => {
|
||||
console.log(isFile);
|
||||
//=> true
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### .file(path)
|
||||
### .dir(path)
|
||||
### .symlink(path)
|
||||
|
||||
Returns a `Promise` for a `boolean` of whether the path is the checked type.
|
||||
|
||||
### .fileSync(path)
|
||||
### .dirSync(path)
|
||||
### .symlinkSync(path)
|
||||
|
||||
Returns a `boolean` of whether the path is the checked type.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
26
node_modules/ava-init/node_modules/read-pkg-up/index.js
generated
vendored
Normal file
26
node_modules/ava-init/node_modules/read-pkg-up/index.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
const findUp = require('find-up');
|
||||
const readPkg = require('read-pkg');
|
||||
|
||||
module.exports = opts => {
|
||||
return findUp('package.json', opts).then(fp => {
|
||||
if (!fp) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return readPkg(fp, opts).then(pkg => ({pkg, path: fp}));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = opts => {
|
||||
const fp = findUp.sync('package.json', opts);
|
||||
|
||||
if (!fp) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
pkg: readPkg.sync(fp, opts),
|
||||
path: fp
|
||||
};
|
||||
};
|
21
node_modules/ava-init/node_modules/read-pkg-up/license
generated
vendored
Normal file
21
node_modules/ava-init/node_modules/read-pkg-up/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.
|
62
node_modules/ava-init/node_modules/read-pkg-up/package.json
generated
vendored
Normal file
62
node_modules/ava-init/node_modules/read-pkg-up/package.json
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "read-pkg-up",
|
||||
"version": "2.0.0",
|
||||
"description": "Read the closest package.json file",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/read-pkg-up",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"json",
|
||||
"read",
|
||||
"parse",
|
||||
"file",
|
||||
"fs",
|
||||
"graceful",
|
||||
"load",
|
||||
"pkg",
|
||||
"package",
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"package",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"dir",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"find-up": "^2.0.0",
|
||||
"read-pkg": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
80
node_modules/ava-init/node_modules/read-pkg-up/readme.md
generated
vendored
Normal file
80
node_modules/ava-init/node_modules/read-pkg-up/readme.md
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
# read-pkg-up [![Build Status](https://travis-ci.org/sindresorhus/read-pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg-up)
|
||||
|
||||
> Read the closest package.json file
|
||||
|
||||
|
||||
## Why
|
||||
|
||||
- [Finds the closest package.json](https://github.com/sindresorhus/find-up)
|
||||
- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
|
||||
- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
|
||||
- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
|
||||
- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save read-pkg-up
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
|
||||
readPkgUp().then(result => {
|
||||
console.log(result);
|
||||
/*
|
||||
{
|
||||
pkg: {
|
||||
name: 'awesome-package',
|
||||
version: '1.0.0',
|
||||
...
|
||||
},
|
||||
path: '/Users/sindresorhus/dev/awesome-package/package.json'
|
||||
}
|
||||
*/
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### readPkgUp([options])
|
||||
|
||||
Returns a `Promise` for the result object.
|
||||
|
||||
### readPkgUp.sync([options])
|
||||
|
||||
Returns the result object.
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `.`
|
||||
|
||||
Directory to start looking for a package.json file.
|
||||
|
||||
##### normalize
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
|
||||
- [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
47
node_modules/ava-init/node_modules/read-pkg/index.js
generated
vendored
Normal file
47
node_modules/ava-init/node_modules/read-pkg/index.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const loadJsonFile = require('load-json-file');
|
||||
const pathType = require('path-type');
|
||||
|
||||
module.exports = (fp, opts) => {
|
||||
if (typeof fp !== 'string') {
|
||||
opts = fp;
|
||||
fp = '.';
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
return pathType.dir(fp)
|
||||
.then(isDir => {
|
||||
if (isDir) {
|
||||
fp = path.join(fp, 'package.json');
|
||||
}
|
||||
|
||||
return loadJsonFile(fp);
|
||||
})
|
||||
.then(x => {
|
||||
if (opts.normalize !== false) {
|
||||
require('normalize-package-data')(x);
|
||||
}
|
||||
|
||||
return x;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = (fp, opts) => {
|
||||
if (typeof fp !== 'string') {
|
||||
opts = fp;
|
||||
fp = '.';
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
|
||||
|
||||
const x = loadJsonFile.sync(fp);
|
||||
|
||||
if (opts.normalize !== false) {
|
||||
require('normalize-package-data')(x);
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
21
node_modules/ava-init/node_modules/read-pkg/license
generated
vendored
Normal file
21
node_modules/ava-init/node_modules/read-pkg/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/ava-init/node_modules/read-pkg/package.json
generated
vendored
Normal file
45
node_modules/ava-init/node_modules/read-pkg/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "read-pkg",
|
||||
"version": "2.0.0",
|
||||
"description": "Read a package.json file",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/read-pkg",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"json",
|
||||
"read",
|
||||
"parse",
|
||||
"file",
|
||||
"fs",
|
||||
"graceful",
|
||||
"load",
|
||||
"pkg",
|
||||
"package",
|
||||
"normalize"
|
||||
],
|
||||
"dependencies": {
|
||||
"load-json-file": "^2.0.0",
|
||||
"normalize-package-data": "^2.3.2",
|
||||
"path-type": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
79
node_modules/ava-init/node_modules/read-pkg/readme.md
generated
vendored
Normal file
79
node_modules/ava-init/node_modules/read-pkg/readme.md
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
# read-pkg [![Build Status](https://travis-ci.org/sindresorhus/read-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg)
|
||||
|
||||
> Read a package.json file
|
||||
|
||||
|
||||
## Why
|
||||
|
||||
- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
|
||||
- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
|
||||
- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
|
||||
- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save read-pkg
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const readPkg = require('read-pkg');
|
||||
|
||||
readPkg().then(pkg => {
|
||||
console.log(pkg);
|
||||
//=> {name: 'read-pkg', ...}
|
||||
});
|
||||
|
||||
readPkg(__dirname).then(pkg => {
|
||||
console.log(pkg);
|
||||
//=> {name: 'read-pkg', ...}
|
||||
});
|
||||
|
||||
readPkg(path.join('unicorn', 'package.json')).then(pkg => {
|
||||
console.log(pkg);
|
||||
//=> {name: 'read-pkg', ...}
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### readPkg([path], [options])
|
||||
|
||||
Returns a `Promise` for the parsed JSON.
|
||||
|
||||
### readPkg.sync([path], [options])
|
||||
|
||||
Returns the parsed JSON.
|
||||
|
||||
#### path
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `.`
|
||||
|
||||
Path to a `package.json` file or its directory.
|
||||
|
||||
#### options
|
||||
|
||||
##### normalize
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
|
||||
- [write-pkg](https://github.com/sindresorhus/write-pkg) - Write a `package.json` file
|
||||
- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
50
node_modules/ava-init/package.json
generated
vendored
Normal file
50
node_modules/ava-init/package.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "ava-init",
|
||||
"version": "0.2.0",
|
||||
"description": "Add AVA to your project",
|
||||
"license": "MIT",
|
||||
"repository": "avajs/ava-init",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"init",
|
||||
"initialize",
|
||||
"add",
|
||||
"create",
|
||||
"setup",
|
||||
"generate",
|
||||
"generator",
|
||||
"scaffold",
|
||||
"ava",
|
||||
"test",
|
||||
"runner"
|
||||
],
|
||||
"dependencies": {
|
||||
"arr-exclude": "^1.0.0",
|
||||
"execa": "^0.5.0",
|
||||
"has-yarn": "^1.0.0",
|
||||
"read-pkg-up": "^2.0.0",
|
||||
"write-pkg": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"dot-prop": "^4.1.0",
|
||||
"temp-write": "^2.0.1",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
63
node_modules/ava-init/readme.md
generated
vendored
Normal file
63
node_modules/ava-init/readme.md
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# ava-init [![Build Status: Linux](https://travis-ci.org/avajs/ava-init.svg?branch=master)](https://travis-ci.org/avajs/ava-init) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/abj17qsw0j1rts7l/branch/master?svg=true)](https://ci.appveyor.com/project/ava/ava-init/branch/master)
|
||||
|
||||
> Add [AVA](https://ava.li) to your project
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save ava-init
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const avaInit = require('ava-init');
|
||||
|
||||
avaInit().then(() => {
|
||||
console.log('done');
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### avaInit([options])
|
||||
|
||||
Returns a `Promise`.
|
||||
|
||||
#### options
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'.'`
|
||||
|
||||
Current working directory.
|
||||
|
||||
#### args
|
||||
|
||||
Type: `Array`<br>
|
||||
Default: CLI arguments *(`process.argv.slice(2)`)*
|
||||
|
||||
For instance, with the arguments `['--foo', '--bar']`, the following will be put in package.json:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "awesome-package",
|
||||
"scripts": {
|
||||
"test": "ava --foo --bar"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## CLI
|
||||
|
||||
Install AVA globally `$ npm install --global ava` and run `$ ava --init [<options>]`.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
7
node_modules/ava/.iron-node.js
generated
vendored
Normal file
7
node_modules/ava/.iron-node.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
app: {
|
||||
openDevToolsDetached: true,
|
||||
hideMainWindow: true
|
||||
},
|
||||
workSpaceDirectory: () => __dirname
|
||||
};
|
350
node_modules/ava/api.js
generated
vendored
Normal file
350
node_modules/ava/api.js
generated
vendored
Normal file
@ -0,0 +1,350 @@
|
||||
'use strict';
|
||||
const EventEmitter = require('events');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const commonPathPrefix = require('common-path-prefix');
|
||||
const uniqueTempDir = require('unique-temp-dir');
|
||||
const findCacheDir = require('find-cache-dir');
|
||||
const resolveCwd = require('resolve-cwd');
|
||||
const debounce = require('lodash.debounce');
|
||||
const autoBind = require('auto-bind');
|
||||
const Promise = require('bluebird');
|
||||
const getPort = require('get-port');
|
||||
const arrify = require('arrify');
|
||||
const ms = require('ms');
|
||||
const babelConfigHelper = require('./lib/babel-config');
|
||||
const CachingPrecompiler = require('./lib/caching-precompiler');
|
||||
const RunStatus = require('./lib/run-status');
|
||||
const AvaError = require('./lib/ava-error');
|
||||
const AvaFiles = require('./lib/ava-files');
|
||||
const fork = require('./lib/fork');
|
||||
|
||||
function resolveModules(modules) {
|
||||
return arrify(modules).map(name => {
|
||||
const modulePath = resolveCwd(name);
|
||||
|
||||
if (modulePath === null) {
|
||||
throw new Error(`Could not resolve required module '${name}'`);
|
||||
}
|
||||
|
||||
return modulePath;
|
||||
});
|
||||
}
|
||||
|
||||
function getBlankResults() {
|
||||
return {
|
||||
stats: {
|
||||
knownFailureCount: 0,
|
||||
testCount: 0,
|
||||
passCount: 0,
|
||||
skipCount: 0,
|
||||
todoCount: 0,
|
||||
failCount: 0
|
||||
},
|
||||
tests: []
|
||||
};
|
||||
}
|
||||
|
||||
class Api extends EventEmitter {
|
||||
constructor(options) {
|
||||
super();
|
||||
autoBind(this);
|
||||
|
||||
this.options = Object.assign({match: []}, options);
|
||||
this.options.require = resolveModules(this.options.require);
|
||||
}
|
||||
_runFile(file, runStatus, execArgv) {
|
||||
const hash = this.precompiler.precompileFile(file);
|
||||
const precompiled = Object.assign({}, this._precompiledHelpers);
|
||||
const resolvedfpath = fs.realpathSync(file);
|
||||
precompiled[resolvedfpath] = hash;
|
||||
|
||||
const options = Object.assign({}, this.options, {precompiled});
|
||||
const emitter = fork(file, options, execArgv);
|
||||
runStatus.observeFork(emitter);
|
||||
|
||||
return emitter;
|
||||
}
|
||||
run(files, options) {
|
||||
return new AvaFiles({cwd: this.options.resolveTestsFrom, files})
|
||||
.findTestFiles()
|
||||
.then(files => this._run(files, options));
|
||||
}
|
||||
_onTimeout(runStatus) {
|
||||
const timeout = ms(this.options.timeout);
|
||||
const err = new AvaError(`Exited because no new tests completed within the last ${timeout}ms of inactivity`);
|
||||
this._handleError(runStatus, err);
|
||||
runStatus.emit('timeout');
|
||||
}
|
||||
_setupTimeout(runStatus) {
|
||||
const timeout = ms(this.options.timeout);
|
||||
|
||||
runStatus._restartTimer = debounce(() => {
|
||||
this._onTimeout(runStatus);
|
||||
}, timeout);
|
||||
|
||||
runStatus._restartTimer();
|
||||
runStatus.on('test', runStatus._restartTimer);
|
||||
}
|
||||
_cancelTimeout(runStatus) {
|
||||
runStatus._restartTimer.cancel();
|
||||
}
|
||||
_setupPrecompiler(files) {
|
||||
const isCacheEnabled = this.options.cacheEnabled !== false;
|
||||
let cacheDir = uniqueTempDir();
|
||||
|
||||
if (isCacheEnabled) {
|
||||
const foundDir = findCacheDir({
|
||||
name: 'ava',
|
||||
files
|
||||
});
|
||||
if (foundDir !== null) {
|
||||
cacheDir = foundDir;
|
||||
}
|
||||
}
|
||||
|
||||
this.options.cacheDir = cacheDir;
|
||||
|
||||
const isPowerAssertEnabled = this.options.powerAssert !== false;
|
||||
return babelConfigHelper.build(this.options.projectDir, cacheDir, this.options.babelConfig, isPowerAssertEnabled)
|
||||
.then(result => {
|
||||
this.precompiler = new CachingPrecompiler({
|
||||
path: cacheDir,
|
||||
getBabelOptions: result.getOptions,
|
||||
babelCacheKeys: result.cacheKeys
|
||||
});
|
||||
});
|
||||
}
|
||||
_precompileHelpers() {
|
||||
this._precompiledHelpers = {};
|
||||
|
||||
// Assumes the tests only load helpers from within the `resolveTestsFrom`
|
||||
// directory. Without arguments this is the `projectDir`, else it's
|
||||
// `process.cwd()` which may be nested too deeply. This will be solved
|
||||
// as we implement RFC 001 and move helper compilation into the worker
|
||||
// processes, avoiding the need for precompilation.
|
||||
return new AvaFiles({cwd: this.options.resolveTestsFrom})
|
||||
.findTestHelpers()
|
||||
.map(file => { // eslint-disable-line array-callback-return
|
||||
const hash = this.precompiler.precompileFile(file);
|
||||
this._precompiledHelpers[file] = hash;
|
||||
});
|
||||
}
|
||||
_run(files, options) {
|
||||
options = options || {};
|
||||
|
||||
const runStatus = new RunStatus({
|
||||
runOnlyExclusive: options.runOnlyExclusive,
|
||||
prefixTitles: this.options.explicitTitles || files.length > 1,
|
||||
base: path.relative(process.cwd(), commonPathPrefix(files)) + path.sep,
|
||||
failFast: this.options.failFast
|
||||
});
|
||||
|
||||
this.emit('test-run', runStatus, files);
|
||||
|
||||
if (files.length === 0) {
|
||||
const err = new AvaError('Couldn\'t find any files to test');
|
||||
this._handleError(runStatus, err);
|
||||
return Promise.resolve(runStatus);
|
||||
}
|
||||
|
||||
return this._setupPrecompiler(files)
|
||||
.then(() => this._precompileHelpers())
|
||||
.then(() => {
|
||||
if (this.options.timeout) {
|
||||
this._setupTimeout(runStatus);
|
||||
}
|
||||
|
||||
let overwatch;
|
||||
if (this.options.concurrency > 0) {
|
||||
const concurrency = this.options.serial ? 1 : this.options.concurrency;
|
||||
overwatch = this._runWithPool(files, runStatus, concurrency);
|
||||
} else {
|
||||
// _runWithoutPool exists to preserve legacy behavior, specifically around `.only`
|
||||
overwatch = this._runWithoutPool(files, runStatus);
|
||||
}
|
||||
|
||||
return overwatch;
|
||||
});
|
||||
}
|
||||
_computeForkExecArgs(files) {
|
||||
const execArgv = this.options.testOnlyExecArgv || process.execArgv;
|
||||
let debugArgIndex = -1;
|
||||
|
||||
// --debug-brk is used in addition to --inspect to break on first line and wait
|
||||
execArgv.some((arg, index) => {
|
||||
const isDebugArg = arg === '--inspect' || arg.indexOf('--inspect=') === 0;
|
||||
if (isDebugArg) {
|
||||
debugArgIndex = index;
|
||||
}
|
||||
|
||||
return isDebugArg;
|
||||
});
|
||||
|
||||
const isInspect = debugArgIndex >= 0;
|
||||
if (!isInspect) {
|
||||
execArgv.some((arg, index) => {
|
||||
const isDebugArg = arg === '--debug' || arg === '--debug-brk' || arg.indexOf('--debug-brk=') === 0 || arg.indexOf('--debug=') === 0;
|
||||
if (isDebugArg) {
|
||||
debugArgIndex = index;
|
||||
}
|
||||
|
||||
return isDebugArg;
|
||||
});
|
||||
}
|
||||
|
||||
if (debugArgIndex === -1) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return Promise
|
||||
.map(files, () => getPort())
|
||||
.map(port => {
|
||||
const forkExecArgv = execArgv.slice();
|
||||
let flagName = isInspect ? '--inspect' : '--debug';
|
||||
const oldValue = forkExecArgv[debugArgIndex];
|
||||
if (oldValue.indexOf('brk') > 0) {
|
||||
flagName += '-brk';
|
||||
}
|
||||
|
||||
forkExecArgv[debugArgIndex] = `${flagName}=${port}`;
|
||||
|
||||
return forkExecArgv;
|
||||
});
|
||||
}
|
||||
_handleError(runStatus, err) {
|
||||
runStatus.handleExceptions({
|
||||
exception: err,
|
||||
file: err.file ? path.relative(process.cwd(), err.file) : undefined
|
||||
});
|
||||
}
|
||||
_runWithoutPool(files, runStatus) {
|
||||
const tests = [];
|
||||
let execArgvList;
|
||||
|
||||
// TODO: This should be cleared at the end of the run
|
||||
runStatus.on('timeout', () => {
|
||||
tests.forEach(fork => {
|
||||
fork.exit();
|
||||
});
|
||||
});
|
||||
|
||||
return this._computeForkExecArgs(files)
|
||||
.then(argvList => {
|
||||
execArgvList = argvList;
|
||||
})
|
||||
.return(files)
|
||||
.each((file, index) => {
|
||||
return new Promise(resolve => {
|
||||
const forkArgs = execArgvList[index];
|
||||
const test = this._runFile(file, runStatus, forkArgs);
|
||||
tests.push(test);
|
||||
test.on('stats', resolve);
|
||||
test.catch(resolve);
|
||||
}).catch(err => {
|
||||
err.results = [];
|
||||
err.file = file;
|
||||
return Promise.reject(err);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
if (this.options.match.length > 0 && !runStatus.hasExclusive) {
|
||||
const err = new AvaError('Couldn\'t find any matching tests');
|
||||
err.file = undefined;
|
||||
err.results = [];
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
const method = this.options.serial ? 'mapSeries' : 'map';
|
||||
const options = {
|
||||
runOnlyExclusive: runStatus.hasExclusive
|
||||
};
|
||||
|
||||
return Promise[method](files, (file, index) => {
|
||||
return tests[index].run(options).catch(err => {
|
||||
err.file = file;
|
||||
this._handleError(runStatus, err);
|
||||
return getBlankResults();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this._handleError(runStatus, err);
|
||||
return err.results;
|
||||
})
|
||||
.tap(results => {
|
||||
// If no tests ran, make sure to tear down the child processes
|
||||
if (results.length === 0) {
|
||||
tests.forEach(test => {
|
||||
test.send('teardown');
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(results => {
|
||||
// Cancel debounced _onTimeout() from firing
|
||||
if (this.options.timeout) {
|
||||
this._cancelTimeout(runStatus);
|
||||
}
|
||||
|
||||
runStatus.processResults(results);
|
||||
|
||||
return runStatus;
|
||||
});
|
||||
}
|
||||
_runWithPool(files, runStatus, concurrency) {
|
||||
const tests = [];
|
||||
let execArgvList;
|
||||
|
||||
runStatus.on('timeout', () => {
|
||||
tests.forEach(fork => {
|
||||
fork.exit();
|
||||
});
|
||||
});
|
||||
|
||||
return this._computeForkExecArgs(files)
|
||||
.then(argvList => {
|
||||
execArgvList = argvList;
|
||||
})
|
||||
.return(files)
|
||||
.map((file, index) => {
|
||||
return new Promise(resolve => {
|
||||
const forkArgs = execArgvList[index];
|
||||
const test = this._runFile(file, runStatus, forkArgs);
|
||||
tests.push(test);
|
||||
|
||||
// If we're looking for matches, run every single test process in exclusive-only mode
|
||||
const options = {
|
||||
runOnlyExclusive: this.options.match.length > 0
|
||||
};
|
||||
|
||||
resolve(test.run(options));
|
||||
}).catch(err => {
|
||||
err.file = file;
|
||||
this._handleError(runStatus, err);
|
||||
return getBlankResults();
|
||||
});
|
||||
}, {concurrency})
|
||||
.then(results => {
|
||||
// Filter out undefined results (usually result of caught exceptions)
|
||||
results = results.filter(Boolean);
|
||||
|
||||
// Cancel debounced _onTimeout() from firing
|
||||
if (this.options.timeout) {
|
||||
this._cancelTimeout(runStatus);
|
||||
}
|
||||
|
||||
if (this.options.match.length > 0 && !runStatus.hasExclusive) {
|
||||
results = [];
|
||||
|
||||
const err = new AvaError('Couldn\'t find any matching tests');
|
||||
this._handleError(runStatus, err);
|
||||
}
|
||||
|
||||
runStatus.processResults(results);
|
||||
|
||||
return runStatus;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Api;
|
27
node_modules/ava/cli.js
generated
vendored
Executable file
27
node_modules/ava/cli.js
generated
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const debug = require('debug')('ava');
|
||||
|
||||
// Prefer the local installation of AVA.
|
||||
const resolveCwd = require('resolve-cwd');
|
||||
const localCLI = resolveCwd('ava/cli');
|
||||
|
||||
// Use `path.relative()` to detect local AVA installation,
|
||||
// because __filename's case is inconsistent on Windows
|
||||
// see https://github.com/nodejs/node/issues/6624
|
||||
if (localCLI && path.relative(localCLI, __filename) !== '') {
|
||||
debug('Using local install of AVA');
|
||||
require(localCLI); // eslint-disable-line import/no-dynamic-require
|
||||
} else {
|
||||
if (debug.enabled) {
|
||||
require('time-require'); // eslint-disable-line import/no-unassigned-import
|
||||
}
|
||||
|
||||
try {
|
||||
require('./lib/cli').run();
|
||||
} catch (err) {
|
||||
console.error(`\n ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
8
node_modules/ava/index.js
generated
vendored
Normal file
8
node_modules/ava/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
// Ensure the same AVA install is loaded by the test file as by the test worker
|
||||
if (process.env.AVA_PATH && process.env.AVA_PATH !== __dirname) {
|
||||
module.exports = require(process.env.AVA_PATH); // eslint-disable-line import/no-dynamic-require
|
||||
} else {
|
||||
module.exports = require('./lib/main');
|
||||
}
|
201
node_modules/ava/index.js.flow
generated
vendored
Normal file
201
node_modules/ava/index.js.flow
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
/* @flow */
|
||||
|
||||
/**
|
||||
* Misc Setup Types
|
||||
*/
|
||||
|
||||
type PromiseLike<R> = {
|
||||
then<U>(
|
||||
onFulfill?: (value: R) => Promise<U> | U,
|
||||
onReject?: (error: any) => Promise<U> | U
|
||||
): Promise<U>;
|
||||
}
|
||||
|
||||
type ObservableLike = {
|
||||
subscribe(observer: (value: {}) => void): void;
|
||||
};
|
||||
|
||||
type SpecialReturnTypes =
|
||||
| PromiseLike<any>
|
||||
| Iterator<any>
|
||||
| ObservableLike;
|
||||
|
||||
type Constructor = Class<{
|
||||
constructor(...args: Array<any>): any
|
||||
}>;
|
||||
|
||||
type ErrorValidator =
|
||||
| Constructor
|
||||
| RegExp
|
||||
| string
|
||||
| ((error: any) => boolean);
|
||||
|
||||
/**
|
||||
* Assertion Types
|
||||
*/
|
||||
|
||||
type AssertContext = {
|
||||
// Passing assertion.
|
||||
pass(message?: string): void;
|
||||
// Failing assertion.
|
||||
fail(message?: string): void;
|
||||
// Assert that value is truthy.
|
||||
truthy(value: mixed, message?: string): void;
|
||||
// Assert that value is falsy.
|
||||
falsy(value: mixed, message?: string): void;
|
||||
// Assert that value is true.
|
||||
true(value: mixed, message?: string): void;
|
||||
// Assert that value is false.
|
||||
false(value: mixed, message?: string): void;
|
||||
// Assert that value is equal to expected.
|
||||
is<U>(value: U, expected: U, message?: string): void;
|
||||
// Assert that value is not equal to expected.
|
||||
not<U>(value: U, expected: U, message?: string): void;
|
||||
// Assert that value is deep equal to expected.
|
||||
deepEqual<U>(value: U, expected: U, message?: string): void;
|
||||
// Assert that value is not deep equal to expected.
|
||||
notDeepEqual<U>(value: U, expected: U, message?: string): void;
|
||||
// Assert that function throws an error or promise rejects.
|
||||
// @param error Can be a constructor, regex, error message or validation function.
|
||||
throws: {
|
||||
(value: PromiseLike<mixed>, error?: ErrorValidator, message?: string): Promise<Error>;
|
||||
(value: () => mixed, error?: ErrorValidator, message?: string): Error;
|
||||
};
|
||||
// Assert that function doesn't throw an error or promise resolves.
|
||||
notThrows: {
|
||||
(value: PromiseLike<mixed>, message?: string): Promise<void>;
|
||||
(value: () => mixed, message?: string): void;
|
||||
};
|
||||
// Assert that contents matches regex.
|
||||
regex(contents: string, regex: RegExp, message?: string): void;
|
||||
// Assert that contents matches a snapshot.
|
||||
snapshot(contents: any, message?: string): void;
|
||||
// Assert that contents does not match regex.
|
||||
notRegex(contents: string, regex: RegExp, message?: string): void;
|
||||
// Assert that error is falsy.
|
||||
ifError(error: any, message?: string): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Context Types
|
||||
*/
|
||||
|
||||
type TestContext = AssertContext & {
|
||||
plan(count: number): void;
|
||||
skip: AssertContext;
|
||||
};
|
||||
type CallbackTestContext = TestContext & { end(): void; };
|
||||
type ContextualTestContext = TestContext & { context: any; };
|
||||
type ContextualCallbackTestContext = CallbackTestContext & { context: any; };
|
||||
|
||||
/**
|
||||
* Test Implementations
|
||||
*/
|
||||
|
||||
type TestFunction<T, R> = {
|
||||
(t: T, ...args: Array<any>): R;
|
||||
title?: (providedTitle: string, ...args: Array<any>) => string;
|
||||
};
|
||||
|
||||
type TestImplementation<T, R> =
|
||||
| TestFunction<T, R>
|
||||
| Array<TestFunction<T, R>>;
|
||||
|
||||
type Test = TestImplementation<TestContext, SpecialReturnTypes | void>;
|
||||
type CallbackTest = TestImplementation<CallbackTestContext, void>;
|
||||
type ContextualTest = TestImplementation<ContextualTestContext, SpecialReturnTypes | void>;
|
||||
type ContextualCallbackTest = TestImplementation<ContextualCallbackTestContext, void>;
|
||||
|
||||
|
||||
/**
|
||||
* Method Types
|
||||
*/
|
||||
|
||||
type TestMethod = {
|
||||
( implementation: Test): void;
|
||||
(name: string, implementation: Test): void;
|
||||
|
||||
serial : TestMethod;
|
||||
before : TestMethod;
|
||||
after : TestMethod;
|
||||
skip : TestMethod;
|
||||
todo : TestMethod;
|
||||
failing : TestMethod;
|
||||
only : TestMethod;
|
||||
beforeEach : TestMethod;
|
||||
afterEach : TestMethod;
|
||||
cb : CallbackTestMethod;
|
||||
always : TestMethod;
|
||||
};
|
||||
|
||||
type CallbackTestMethod = {
|
||||
( implementation: CallbackTest): void;
|
||||
(name: string, implementation: CallbackTest): void;
|
||||
|
||||
serial : CallbackTestMethod;
|
||||
before : CallbackTestMethod;
|
||||
after : CallbackTestMethod;
|
||||
skip : CallbackTestMethod;
|
||||
todo : CallbackTestMethod;
|
||||
failing : CallbackTestMethod;
|
||||
only : CallbackTestMethod;
|
||||
beforeEach : CallbackTestMethod;
|
||||
afterEach : CallbackTestMethod;
|
||||
cb : CallbackTestMethod;
|
||||
always : CallbackTestMethod;
|
||||
};
|
||||
|
||||
type ContextualTestMethod = {
|
||||
( implementation: ContextualTest): void;
|
||||
(name: string, implementation: ContextualTest): void;
|
||||
|
||||
serial : ContextualTestMethod;
|
||||
before : ContextualTestMethod;
|
||||
after : ContextualTestMethod;
|
||||
skip : ContextualTestMethod;
|
||||
todo : ContextualTestMethod;
|
||||
failing : ContextualTestMethod;
|
||||
only : ContextualTestMethod;
|
||||
beforeEach : ContextualTestMethod;
|
||||
afterEach : ContextualTestMethod;
|
||||
cb : ContextualCallbackTestMethod;
|
||||
always : ContextualTestMethod;
|
||||
};
|
||||
|
||||
type ContextualCallbackTestMethod = {
|
||||
( implementation: ContextualCallbackTest): void;
|
||||
(name: string, implementation: ContextualCallbackTest): void;
|
||||
|
||||
serial : ContextualCallbackTestMethod;
|
||||
before : ContextualCallbackTestMethod;
|
||||
after : ContextualCallbackTestMethod;
|
||||
skip : ContextualCallbackTestMethod;
|
||||
todo : ContextualCallbackTestMethod;
|
||||
failing : ContextualCallbackTestMethod;
|
||||
only : ContextualCallbackTestMethod;
|
||||
beforeEach : ContextualCallbackTestMethod;
|
||||
afterEach : ContextualCallbackTestMethod;
|
||||
cb : ContextualCallbackTestMethod;
|
||||
always : ContextualCallbackTestMethod;
|
||||
};
|
||||
|
||||
/**
|
||||
* Public API
|
||||
*/
|
||||
|
||||
declare module.exports: {
|
||||
( run: ContextualTest): void;
|
||||
(name: string, run: ContextualTest): void;
|
||||
|
||||
beforeEach : ContextualTestMethod;
|
||||
afterEach : ContextualTestMethod;
|
||||
serial : ContextualTestMethod;
|
||||
before : ContextualTestMethod;
|
||||
after : ContextualTestMethod;
|
||||
skip : ContextualTestMethod;
|
||||
todo : ContextualTestMethod;
|
||||
failing : ContextualTestMethod;
|
||||
only : ContextualTestMethod;
|
||||
cb : ContextualCallbackTestMethod;
|
||||
always : ContextualTestMethod;
|
||||
};
|
378
node_modules/ava/lib/assert.js
generated
vendored
Normal file
378
node_modules/ava/lib/assert.js
generated
vendored
Normal file
@ -0,0 +1,378 @@
|
||||
'use strict';
|
||||
const coreAssert = require('core-assert');
|
||||
const deepEqual = require('lodash.isequal');
|
||||
const observableToPromise = require('observable-to-promise');
|
||||
const isObservable = require('is-observable');
|
||||
const isPromise = require('is-promise');
|
||||
const jestDiff = require('jest-diff');
|
||||
const enhanceAssert = require('./enhance-assert');
|
||||
const formatAssertError = require('./format-assert-error');
|
||||
|
||||
class AssertionError extends Error {
|
||||
constructor(opts) {
|
||||
super(opts.message || '');
|
||||
this.name = 'AssertionError';
|
||||
|
||||
this.assertion = opts.assertion;
|
||||
this.fixedSource = opts.fixedSource;
|
||||
this.improperUsage = opts.improperUsage || false;
|
||||
this.operator = opts.operator;
|
||||
this.values = opts.values || [];
|
||||
|
||||
// Reserved for power-assert statements
|
||||
this.statements = [];
|
||||
|
||||
if (opts.stack) {
|
||||
this.stack = opts.stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.AssertionError = AssertionError;
|
||||
|
||||
function getStack() {
|
||||
const obj = {};
|
||||
Error.captureStackTrace(obj, getStack);
|
||||
return obj.stack;
|
||||
}
|
||||
|
||||
function wrapAssertions(callbacks) {
|
||||
const pass = callbacks.pass;
|
||||
const pending = callbacks.pending;
|
||||
const fail = callbacks.fail;
|
||||
|
||||
const noop = () => {};
|
||||
const makeNoop = () => noop;
|
||||
const makeRethrow = reason => () => {
|
||||
throw reason;
|
||||
};
|
||||
|
||||
const assertions = {
|
||||
pass() {
|
||||
pass(this);
|
||||
},
|
||||
|
||||
fail(message) {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'fail',
|
||||
message: message || 'Test failed via `t.fail()`'
|
||||
}));
|
||||
},
|
||||
|
||||
is(actual, expected, message) {
|
||||
if (actual === expected) {
|
||||
pass(this);
|
||||
} else {
|
||||
const diff = formatAssertError.formatDiff(actual, expected);
|
||||
const values = diff ? [diff] : [
|
||||
formatAssertError.formatWithLabel('Actual:', actual),
|
||||
formatAssertError.formatWithLabel('Must be strictly equal to:', expected)
|
||||
];
|
||||
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'is',
|
||||
message,
|
||||
operator: '===',
|
||||
values
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
not(actual, expected, message) {
|
||||
if (actual === expected) {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'not',
|
||||
message,
|
||||
operator: '!==',
|
||||
values: [formatAssertError.formatWithLabel('Value is strictly equal:', actual)]
|
||||
}));
|
||||
} else {
|
||||
pass(this);
|
||||
}
|
||||
},
|
||||
|
||||
deepEqual(actual, expected, message) {
|
||||
if (deepEqual(actual, expected)) {
|
||||
pass(this);
|
||||
} else {
|
||||
const diff = formatAssertError.formatDiff(actual, expected);
|
||||
const values = diff ? [diff] : [
|
||||
formatAssertError.formatWithLabel('Actual:', actual),
|
||||
formatAssertError.formatWithLabel('Must be deeply equal to:', expected)
|
||||
];
|
||||
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'deepEqual',
|
||||
message,
|
||||
values
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
notDeepEqual(actual, expected, message) {
|
||||
if (deepEqual(actual, expected)) {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'notDeepEqual',
|
||||
message,
|
||||
values: [formatAssertError.formatWithLabel('Value is deeply equal:', actual)]
|
||||
}));
|
||||
} else {
|
||||
pass(this);
|
||||
}
|
||||
},
|
||||
|
||||
throws(fn, err, message) {
|
||||
let promise;
|
||||
if (isPromise(fn)) {
|
||||
promise = fn;
|
||||
} else if (isObservable(fn)) {
|
||||
promise = observableToPromise(fn);
|
||||
} else if (typeof fn !== 'function') {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'throws',
|
||||
improperUsage: true,
|
||||
message: '`t.throws()` must be called with a function, Promise, or Observable',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', fn)]
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
let coreAssertThrowsErrorArg;
|
||||
if (typeof err === 'string') {
|
||||
const expectedMessage = err;
|
||||
coreAssertThrowsErrorArg = error => error.message === expectedMessage;
|
||||
} else {
|
||||
// Assume it's a constructor function or regular expression
|
||||
coreAssertThrowsErrorArg = err;
|
||||
}
|
||||
|
||||
const test = (fn, stack) => {
|
||||
let actual;
|
||||
let threw = false;
|
||||
try {
|
||||
coreAssert.throws(() => {
|
||||
try {
|
||||
fn();
|
||||
} catch (err) {
|
||||
actual = err;
|
||||
threw = true;
|
||||
throw err;
|
||||
}
|
||||
}, coreAssertThrowsErrorArg);
|
||||
return actual;
|
||||
} catch (err) {
|
||||
const values = threw ?
|
||||
[formatAssertError.formatWithLabel('Threw unexpected exception:', actual)] :
|
||||
null;
|
||||
|
||||
throw new AssertionError({
|
||||
assertion: 'throws',
|
||||
message,
|
||||
stack,
|
||||
values
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (promise) {
|
||||
// Record stack before it gets lost in the promise chain.
|
||||
const stack = getStack();
|
||||
const intermediate = promise.then(makeNoop, makeRethrow).then(fn => test(fn, stack));
|
||||
pending(this, intermediate);
|
||||
// Don't reject the returned promise, even if the assertion fails.
|
||||
return intermediate.catch(noop);
|
||||
}
|
||||
|
||||
try {
|
||||
const retval = test(fn);
|
||||
pass(this);
|
||||
return retval;
|
||||
} catch (err) {
|
||||
fail(this, err);
|
||||
}
|
||||
},
|
||||
|
||||
notThrows(fn, message) {
|
||||
let promise;
|
||||
if (isPromise(fn)) {
|
||||
promise = fn;
|
||||
} else if (isObservable(fn)) {
|
||||
promise = observableToPromise(fn);
|
||||
} else if (typeof fn !== 'function') {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'notThrows',
|
||||
improperUsage: true,
|
||||
message: '`t.notThrows()` must be called with a function, Promise, or Observable',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', fn)]
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
const test = (fn, stack) => {
|
||||
try {
|
||||
coreAssert.doesNotThrow(fn);
|
||||
} catch (err) {
|
||||
throw new AssertionError({
|
||||
assertion: 'notThrows',
|
||||
message,
|
||||
stack,
|
||||
values: [formatAssertError.formatWithLabel('Threw:', err.actual)]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (promise) {
|
||||
// Record stack before it gets lost in the promise chain.
|
||||
const stack = getStack();
|
||||
const intermediate = promise.then(noop, reason => test(makeRethrow(reason), stack));
|
||||
pending(this, intermediate);
|
||||
// Don't reject the returned promise, even if the assertion fails.
|
||||
return intermediate.catch(noop);
|
||||
}
|
||||
|
||||
try {
|
||||
test(fn);
|
||||
pass(this);
|
||||
} catch (err) {
|
||||
fail(this, err);
|
||||
}
|
||||
},
|
||||
|
||||
ifError(actual, message) {
|
||||
if (actual) {
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'ifError',
|
||||
message,
|
||||
values: [formatAssertError.formatWithLabel('Error:', actual)]
|
||||
}));
|
||||
} else {
|
||||
pass(this);
|
||||
}
|
||||
},
|
||||
|
||||
snapshot(actual, message) {
|
||||
const state = this._test.getSnapshotState();
|
||||
const result = state.match(this.title, actual);
|
||||
if (result.pass) {
|
||||
pass(this);
|
||||
} else {
|
||||
const diff = jestDiff(result.expected.trim(), result.actual.trim(), {expand: true})
|
||||
// Remove annotation
|
||||
.split('\n')
|
||||
.slice(3)
|
||||
.join('\n');
|
||||
fail(this, new AssertionError({
|
||||
assertion: 'snapshot',
|
||||
message: message || 'Did not match snapshot',
|
||||
values: [{label: 'Difference:', formatted: diff}]
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const enhancedAssertions = enhanceAssert(pass, fail, {
|
||||
truthy(actual, message) {
|
||||
if (!actual) {
|
||||
throw new AssertionError({
|
||||
assertion: 'truthy',
|
||||
message,
|
||||
operator: '!!',
|
||||
values: [formatAssertError.formatWithLabel('Value is not truthy:', actual)]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
falsy(actual, message) {
|
||||
if (actual) {
|
||||
throw new AssertionError({
|
||||
assertion: 'falsy',
|
||||
message,
|
||||
operator: '!',
|
||||
values: [formatAssertError.formatWithLabel('Value is not falsy:', actual)]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
true(actual, message) {
|
||||
if (actual !== true) {
|
||||
throw new AssertionError({
|
||||
assertion: 'true',
|
||||
message,
|
||||
values: [formatAssertError.formatWithLabel('Value is not `true`:', actual)]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
false(actual, message) {
|
||||
if (actual !== false) {
|
||||
throw new AssertionError({
|
||||
assertion: 'false',
|
||||
message,
|
||||
values: [formatAssertError.formatWithLabel('Value is not `false`:', actual)]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
regex(string, regex, message) {
|
||||
if (typeof string !== 'string') {
|
||||
throw new AssertionError({
|
||||
assertion: 'regex',
|
||||
improperUsage: true,
|
||||
message: '`t.regex()` must be called with a string',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', string)]
|
||||
});
|
||||
}
|
||||
if (!(regex instanceof RegExp)) {
|
||||
throw new AssertionError({
|
||||
assertion: 'regex',
|
||||
improperUsage: true,
|
||||
message: '`t.regex()` must be called with a regular expression',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', regex)]
|
||||
});
|
||||
}
|
||||
|
||||
if (!regex.test(string)) {
|
||||
throw new AssertionError({
|
||||
assertion: 'regex',
|
||||
message,
|
||||
values: [
|
||||
formatAssertError.formatWithLabel('Value must match expression:', string),
|
||||
formatAssertError.formatWithLabel('Regular expression:', regex)
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
notRegex(string, regex, message) {
|
||||
if (typeof string !== 'string') {
|
||||
throw new AssertionError({
|
||||
assertion: 'notRegex',
|
||||
improperUsage: true,
|
||||
message: '`t.notRegex()` must be called with a string',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', string)]
|
||||
});
|
||||
}
|
||||
if (!(regex instanceof RegExp)) {
|
||||
throw new AssertionError({
|
||||
assertion: 'notRegex',
|
||||
improperUsage: true,
|
||||
message: '`t.notRegex()` must be called with a regular expression',
|
||||
values: [formatAssertError.formatWithLabel('Called with:', regex)]
|
||||
});
|
||||
}
|
||||
|
||||
if (regex.test(string)) {
|
||||
throw new AssertionError({
|
||||
assertion: 'notRegex',
|
||||
message,
|
||||
values: [
|
||||
formatAssertError.formatWithLabel('Value must not match expression:', string),
|
||||
formatAssertError.formatWithLabel('Regular expression:', regex)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Object.assign(assertions, enhancedAssertions);
|
||||
}
|
||||
exports.wrapAssertions = wrapAssertions;
|
10
node_modules/ava/lib/ava-error.js
generated
vendored
Normal file
10
node_modules/ava/lib/ava-error.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
class AvaError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'AvaError';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AvaError;
|
282
node_modules/ava/lib/ava-files.js
generated
vendored
Normal file
282
node_modules/ava/lib/ava-files.js
generated
vendored
Normal file
@ -0,0 +1,282 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Promise = require('bluebird');
|
||||
const slash = require('slash');
|
||||
const globby = require('globby');
|
||||
const flatten = require('lodash.flatten');
|
||||
const autoBind = require('auto-bind');
|
||||
const defaultIgnore = require('ignore-by-default').directories();
|
||||
const multimatch = require('multimatch');
|
||||
|
||||
function handlePaths(files, excludePatterns, globOptions) {
|
||||
// Convert Promise to Bluebird
|
||||
files = Promise.resolve(globby(files.concat(excludePatterns), globOptions));
|
||||
|
||||
const searchedParents = new Set();
|
||||
const foundFiles = new Set();
|
||||
|
||||
function alreadySearchingParent(dir) {
|
||||
if (searchedParents.has(dir)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const parentDir = path.dirname(dir);
|
||||
|
||||
if (parentDir === dir) {
|
||||
// We have reached the root path
|
||||
return false;
|
||||
}
|
||||
|
||||
return alreadySearchingParent(parentDir);
|
||||
}
|
||||
|
||||
return files
|
||||
.map(file => {
|
||||
file = path.resolve(globOptions.cwd, file);
|
||||
|
||||
if (fs.statSync(file).isDirectory()) {
|
||||
if (alreadySearchingParent(file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
searchedParents.add(file);
|
||||
|
||||
let pattern = path.join(file, '**', '*.js');
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Always use `/` in patterns, harmonizing matching across platforms
|
||||
pattern = slash(pattern);
|
||||
}
|
||||
|
||||
return handlePaths([pattern], excludePatterns, globOptions);
|
||||
}
|
||||
|
||||
// `globby` returns slashes even on Windows. Normalize here so the file
|
||||
// paths are consistently platform-accurate as tests are run.
|
||||
return path.normalize(file);
|
||||
})
|
||||
.then(flatten)
|
||||
.filter(file => file && path.extname(file) === '.js')
|
||||
.filter(file => {
|
||||
if (path.basename(file)[0] === '_' && globOptions.includeUnderscoredFiles !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.map(file => path.resolve(file))
|
||||
.filter(file => {
|
||||
const alreadyFound = foundFiles.has(file);
|
||||
foundFiles.add(file);
|
||||
return !alreadyFound;
|
||||
});
|
||||
}
|
||||
|
||||
const defaultExcludePatterns = () => [
|
||||
'!**/node_modules/**',
|
||||
'!**/fixtures/**',
|
||||
'!**/helpers/**'
|
||||
];
|
||||
|
||||
const defaultIncludePatterns = () => [
|
||||
'test.js',
|
||||
'test-*.js',
|
||||
'test',
|
||||
'**/__tests__',
|
||||
'**/*.test.js'
|
||||
];
|
||||
|
||||
const defaultHelperPatterns = () => [
|
||||
'**/__tests__/helpers/**/*.js',
|
||||
'**/__tests__/**/_*.js',
|
||||
'**/test/helpers/**/*.js',
|
||||
'**/test/**/_*.js'
|
||||
];
|
||||
|
||||
const getDefaultIgnorePatterns = () => defaultIgnore.map(dir => `${dir}/**/*`);
|
||||
|
||||
// Used on paths before they're passed to multimatch to harmonize matching
|
||||
// across platforms
|
||||
const matchable = process.platform === 'win32' ? slash : (path => path);
|
||||
|
||||
class AvaFiles {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
|
||||
let files = (options.files || []).map(file => {
|
||||
// `./` should be removed from the beginning of patterns because
|
||||
// otherwise they won't match change events from Chokidar
|
||||
if (file.slice(0, 2) === './') {
|
||||
return file.slice(2);
|
||||
}
|
||||
|
||||
return file;
|
||||
});
|
||||
|
||||
if (files.length === 0) {
|
||||
files = defaultIncludePatterns();
|
||||
}
|
||||
|
||||
this.excludePatterns = defaultExcludePatterns();
|
||||
this.files = files;
|
||||
this.sources = options.sources || [];
|
||||
this.cwd = options.cwd || process.cwd();
|
||||
|
||||
autoBind(this);
|
||||
}
|
||||
findTestFiles() {
|
||||
return handlePaths(this.files, this.excludePatterns, {
|
||||
cwd: this.cwd,
|
||||
cache: Object.create(null),
|
||||
statCache: Object.create(null),
|
||||
realpathCache: Object.create(null),
|
||||
symlinks: Object.create(null)
|
||||
});
|
||||
}
|
||||
findTestHelpers() {
|
||||
return handlePaths(defaultHelperPatterns(), ['!**/node_modules/**'], {
|
||||
cwd: this.cwd,
|
||||
includeUnderscoredFiles: true,
|
||||
cache: Object.create(null),
|
||||
statCache: Object.create(null),
|
||||
realpathCache: Object.create(null),
|
||||
symlinks: Object.create(null)
|
||||
});
|
||||
}
|
||||
isSource(filePath) {
|
||||
let mixedPatterns = [];
|
||||
const defaultIgnorePatterns = getDefaultIgnorePatterns();
|
||||
const overrideDefaultIgnorePatterns = [];
|
||||
|
||||
let hasPositivePattern = false;
|
||||
this.sources.forEach(pattern => {
|
||||
mixedPatterns.push(pattern);
|
||||
|
||||
// TODO: Why not just `pattern[0] !== '!'`?
|
||||
if (!hasPositivePattern && pattern[0] !== '!') {
|
||||
hasPositivePattern = true;
|
||||
}
|
||||
|
||||
// Extract patterns that start with an ignored directory. These need to be
|
||||
// rematched separately.
|
||||
if (defaultIgnore.indexOf(pattern.split('/')[0]) >= 0) {
|
||||
overrideDefaultIgnorePatterns.push(pattern);
|
||||
}
|
||||
});
|
||||
|
||||
// Same defaults as used for Chokidar
|
||||
if (!hasPositivePattern) {
|
||||
mixedPatterns = ['package.json', '**/*.js'].concat(mixedPatterns);
|
||||
}
|
||||
|
||||
filePath = matchable(filePath);
|
||||
|
||||
// Ignore paths outside the current working directory.
|
||||
// They can't be matched to a pattern.
|
||||
if (/^\.\.\//.test(filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isSource = multimatch(filePath, mixedPatterns).length === 1;
|
||||
if (!isSource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isIgnored = multimatch(filePath, defaultIgnorePatterns).length === 1;
|
||||
if (!isIgnored) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const isErroneouslyIgnored = multimatch(filePath, overrideDefaultIgnorePatterns).length === 1;
|
||||
if (isErroneouslyIgnored) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
isTest(filePath) {
|
||||
const excludePatterns = this.excludePatterns;
|
||||
const initialPatterns = this.files.concat(excludePatterns);
|
||||
|
||||
// Like in `api.js`, tests must be `.js` files and not start with `_`
|
||||
if (path.extname(filePath) !== '.js' || path.basename(filePath)[0] === '_') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the entire path matches a pattern
|
||||
if (multimatch(matchable(filePath), initialPatterns).length === 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the path contains any directory components
|
||||
const dirname = path.dirname(filePath);
|
||||
if (dirname === '.') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compute all possible subpaths. Note that the dirname is assumed to be
|
||||
// relative to the working directory, without a leading `./`.
|
||||
const subpaths = dirname.split(/[\\/]/).reduce((subpaths, component) => {
|
||||
const parent = subpaths[subpaths.length - 1];
|
||||
|
||||
if (parent) {
|
||||
// Always use `/`` to makes multimatch consistent across platforms
|
||||
subpaths.push(`${parent}/${component}`);
|
||||
} else {
|
||||
subpaths.push(component);
|
||||
}
|
||||
|
||||
return subpaths;
|
||||
}, []);
|
||||
|
||||
// Check if any of the possible subpaths match a pattern. If so, generate a
|
||||
// new pattern with **/*.js.
|
||||
const recursivePatterns = subpaths
|
||||
.filter(subpath => multimatch(subpath, initialPatterns).length === 1)
|
||||
// Always use `/` to makes multimatch consistent across platforms
|
||||
.map(subpath => `${subpath}/**/*.js`);
|
||||
|
||||
// See if the entire path matches any of the subpaths patterns, taking the
|
||||
// excludePatterns into account. This mimicks the behavior in api.js
|
||||
return multimatch(matchable(filePath), recursivePatterns.concat(excludePatterns)).length === 1;
|
||||
}
|
||||
getChokidarPatterns() {
|
||||
let paths = [];
|
||||
let ignored = [];
|
||||
|
||||
this.sources.forEach(pattern => {
|
||||
if (pattern[0] === '!') {
|
||||
ignored.push(pattern.slice(1));
|
||||
} else {
|
||||
paths.push(pattern);
|
||||
}
|
||||
});
|
||||
|
||||
// Allow source patterns to override the default ignore patterns. Chokidar
|
||||
// ignores paths that match the list of ignored patterns. It uses anymatch
|
||||
// under the hood, which supports negation patterns. For any source pattern
|
||||
// that starts with an ignored directory, ensure the corresponding negation
|
||||
// pattern is added to the ignored paths.
|
||||
const overrideDefaultIgnorePatterns = paths
|
||||
.filter(pattern => defaultIgnore.indexOf(pattern.split('/')[0]) >= 0)
|
||||
.map(pattern => `!${pattern}`);
|
||||
|
||||
ignored = getDefaultIgnorePatterns().concat(ignored, overrideDefaultIgnorePatterns);
|
||||
|
||||
if (paths.length === 0) {
|
||||
paths = ['package.json', '**/*.js'];
|
||||
}
|
||||
|
||||
paths = paths.concat(this.files);
|
||||
|
||||
return {
|
||||
paths,
|
||||
ignored
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AvaFiles;
|
||||
module.exports.defaultIncludePatterns = defaultIncludePatterns;
|
||||
module.exports.defaultExcludePatterns = defaultExcludePatterns;
|
148
node_modules/ava/lib/babel-config.js
generated
vendored
Normal file
148
node_modules/ava/lib/babel-config.js
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const figures = require('figures');
|
||||
const configManager = require('hullabaloo-config-manager');
|
||||
const md5Hex = require('md5-hex');
|
||||
const mkdirp = require('mkdirp');
|
||||
const colors = require('./colors');
|
||||
|
||||
function validate(conf) {
|
||||
if (conf === undefined || conf === null) {
|
||||
conf = 'default';
|
||||
}
|
||||
|
||||
// Check for valid babel config shortcuts (can be either `default` or `inherit`)
|
||||
const isValidShortcut = conf === 'default' || conf === 'inherit';
|
||||
|
||||
if (!conf || (typeof conf === 'string' && !isValidShortcut)) {
|
||||
let message = colors.error(figures.cross);
|
||||
message += ' Unexpected Babel configuration for AVA. ';
|
||||
message += 'See ' + chalk.underline('https://github.com/avajs/ava#es2015-support') + ' for allowed values.';
|
||||
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
const SOURCE = '(AVA) Base Babel config';
|
||||
const AVA_DIR = path.join(__dirname, '..');
|
||||
|
||||
function verifyExistingOptions(verifierFile, baseConfig, cache) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
resolve(fs.readFileSync(verifierFile));
|
||||
} catch (err) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
resolve(null);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(buffer => {
|
||||
if (!buffer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const verifier = configManager.restoreVerifier(buffer);
|
||||
const fixedSourceHashes = new Map();
|
||||
fixedSourceHashes.set(baseConfig.source, baseConfig.hash);
|
||||
if (baseConfig.extends) {
|
||||
fixedSourceHashes.set(baseConfig.extends.source, baseConfig.extends.hash);
|
||||
}
|
||||
return verifier.verifyCurrentEnv({sources: fixedSourceHashes}, cache)
|
||||
.then(result => {
|
||||
if (!result.cacheKeys) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result.dependenciesChanged) {
|
||||
fs.writeFileSync(verifierFile, result.verifier.toBuffer());
|
||||
}
|
||||
|
||||
return result.cacheKeys;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resolveOptions(baseConfig, cache, optionsFile, verifierFile) {
|
||||
return configManager.fromConfig(baseConfig, {cache})
|
||||
.then(result => {
|
||||
fs.writeFileSync(optionsFile, result.generateModule());
|
||||
|
||||
return result.createVerifier()
|
||||
.then(verifier => {
|
||||
fs.writeFileSync(verifierFile, verifier.toBuffer());
|
||||
return verifier.cacheKeysForCurrentEnv();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function build(projectDir, cacheDir, userOptions, powerAssert) {
|
||||
// Compute a seed based on the Node.js version and the project directory.
|
||||
// Dependency hashes may vary based on the Node.js version, e.g. with the
|
||||
// @ava/stage-4 Babel preset. Sources and dependencies paths are absolute in
|
||||
// the generated module and verifier state. Those paths wouldn't necessarily
|
||||
// be valid if the project directory changes.
|
||||
const seed = md5Hex([process.versions.node, projectDir]);
|
||||
|
||||
// Ensure cacheDir exists
|
||||
mkdirp.sync(cacheDir);
|
||||
|
||||
// The file names predict where valid options may be cached, and thus should
|
||||
// include the seed.
|
||||
const optionsFile = path.join(cacheDir, `${seed}.babel-options.js`);
|
||||
const verifierFile = path.join(cacheDir, `${seed}.verifier.bin`);
|
||||
|
||||
const baseOptions = {
|
||||
babelrc: false,
|
||||
presets: [
|
||||
['@ava/transform-test-files', {powerAssert}]
|
||||
]
|
||||
};
|
||||
if (userOptions === 'default') {
|
||||
baseOptions.presets.unshift('@ava/stage-4');
|
||||
}
|
||||
|
||||
const baseConfig = configManager.createConfig({
|
||||
dir: AVA_DIR, // Presets are resolved relative to this directory
|
||||
hash: md5Hex(JSON.stringify(baseOptions)),
|
||||
json5: false,
|
||||
options: baseOptions,
|
||||
source: SOURCE
|
||||
});
|
||||
|
||||
if (userOptions !== 'default') {
|
||||
baseConfig.extend(configManager.createConfig({
|
||||
dir: projectDir,
|
||||
options: userOptions === 'inherit' ?
|
||||
{babelrc: true} :
|
||||
userOptions,
|
||||
source: path.join(projectDir, 'package.json') + '#ava.babel',
|
||||
hash: md5Hex(JSON.stringify(userOptions))
|
||||
}));
|
||||
}
|
||||
|
||||
const cache = configManager.prepareCache();
|
||||
return verifyExistingOptions(verifierFile, baseConfig, cache)
|
||||
.then(cacheKeys => {
|
||||
if (cacheKeys) {
|
||||
return cacheKeys;
|
||||
}
|
||||
|
||||
return resolveOptions(baseConfig, cache, optionsFile, verifierFile);
|
||||
})
|
||||
.then(cacheKeys => ({
|
||||
getOptions: require(optionsFile).getOptions, // eslint-disable-line import/no-dynamic-require
|
||||
// Include the seed in the cache keys used to store compilation results.
|
||||
cacheKeys: Object.assign({seed}, cacheKeys)
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
build
|
||||
};
|
37
node_modules/ava/lib/beautify-stack.js
generated
vendored
Normal file
37
node_modules/ava/lib/beautify-stack.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
const StackUtils = require('stack-utils');
|
||||
const cleanStack = require('clean-stack');
|
||||
const debug = require('debug')('ava');
|
||||
|
||||
// Ignore unimportant stack trace lines
|
||||
let ignoreStackLines = [];
|
||||
|
||||
const avaInternals = /\/ava\/(?:lib\/)?[\w-]+\.js:\d+:\d+\)?$/;
|
||||
const avaDependencies = /\/node_modules\/(?:bluebird|empower-core|(?:ava\/node_modules\/)?(?:babel-runtime|core-js))\//;
|
||||
|
||||
if (!debug.enabled) {
|
||||
ignoreStackLines = StackUtils.nodeInternals();
|
||||
ignoreStackLines.push(avaInternals);
|
||||
ignoreStackLines.push(avaDependencies);
|
||||
}
|
||||
|
||||
const stackUtils = new StackUtils({internals: ignoreStackLines});
|
||||
|
||||
module.exports = stack => {
|
||||
if (!stack) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/tapjs/stack-utils/issues/14
|
||||
// TODO: fix it in `stack-utils`
|
||||
stack = cleanStack(stack);
|
||||
|
||||
const title = stack.split('\n')[0];
|
||||
const lines = stackUtils
|
||||
.clean(stack)
|
||||
.split('\n')
|
||||
.map(x => ` ${x}`)
|
||||
.join('\n');
|
||||
|
||||
return `${title}\n${lines}`;
|
||||
};
|
103
node_modules/ava/lib/caching-precompiler.js
generated
vendored
Normal file
103
node_modules/ava/lib/caching-precompiler.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const convertSourceMap = require('convert-source-map');
|
||||
const cachingTransform = require('caching-transform');
|
||||
const packageHash = require('package-hash');
|
||||
const stripBomBuf = require('strip-bom-buf');
|
||||
const autoBind = require('auto-bind');
|
||||
const md5Hex = require('md5-hex');
|
||||
|
||||
function getSourceMap(filePath, code) {
|
||||
let sourceMap = convertSourceMap.fromSource(code);
|
||||
|
||||
if (!sourceMap) {
|
||||
const dirPath = path.dirname(filePath);
|
||||
sourceMap = convertSourceMap.fromMapFileSource(code, dirPath);
|
||||
}
|
||||
|
||||
if (sourceMap) {
|
||||
sourceMap = sourceMap.toObject();
|
||||
}
|
||||
|
||||
return sourceMap;
|
||||
}
|
||||
|
||||
class CachingPrecompiler {
|
||||
constructor(options) {
|
||||
autoBind(this);
|
||||
|
||||
this.getBabelOptions = options.getBabelOptions;
|
||||
this.babelCacheKeys = options.babelCacheKeys;
|
||||
this.cacheDirPath = options.path;
|
||||
this.fileHashes = {};
|
||||
this.transform = this._createTransform();
|
||||
}
|
||||
precompileFile(filePath) {
|
||||
if (!this.fileHashes[filePath]) {
|
||||
const source = stripBomBuf(fs.readFileSync(filePath));
|
||||
this.transform(source, filePath);
|
||||
}
|
||||
|
||||
return this.fileHashes[filePath];
|
||||
}
|
||||
// Conditionally called by caching-transform when precompiling is required
|
||||
_init() {
|
||||
this.babel = require('babel-core');
|
||||
return this._transform;
|
||||
}
|
||||
_transform(code, filePath, hash) {
|
||||
code = code.toString();
|
||||
|
||||
let result;
|
||||
const originalBabelDisableCache = process.env.BABEL_DISABLE_CACHE;
|
||||
try {
|
||||
// Disable Babel's cache. AVA has good cache management already.
|
||||
process.env.BABEL_DISABLE_CACHE = '1';
|
||||
|
||||
result = this.babel.transform(code, Object.assign(this.getBabelOptions(), {
|
||||
inputSourceMap: getSourceMap(filePath, code),
|
||||
filename: filePath,
|
||||
sourceMaps: true,
|
||||
ast: false
|
||||
}));
|
||||
} finally {
|
||||
// Restore the original value. It is passed to workers, where users may
|
||||
// not want Babel's cache to be disabled.
|
||||
process.env.BABEL_DISABLE_CACHE = originalBabelDisableCache;
|
||||
}
|
||||
|
||||
// Save source map
|
||||
const mapPath = path.join(this.cacheDirPath, `${hash}.js.map`);
|
||||
fs.writeFileSync(mapPath, JSON.stringify(result.map));
|
||||
|
||||
// Append source map comment to transformed code
|
||||
// So that other libraries (like nyc) can find the source map
|
||||
const dirPath = path.dirname(filePath);
|
||||
const relativeMapPath = path.relative(dirPath, mapPath);
|
||||
const comment = convertSourceMap.generateMapFileComment(relativeMapPath);
|
||||
|
||||
return `${result.code}\n${comment}`;
|
||||
}
|
||||
_createTransform() {
|
||||
const salt = packageHash.sync([
|
||||
require.resolve('../package.json'),
|
||||
require.resolve('babel-core/package.json')
|
||||
], this.babelCacheKeys);
|
||||
|
||||
return cachingTransform({
|
||||
factory: this._init,
|
||||
cacheDir: this.cacheDirPath,
|
||||
hash: this._generateHash,
|
||||
salt,
|
||||
ext: '.js'
|
||||
});
|
||||
}
|
||||
_generateHash(code, filePath, salt) {
|
||||
const hash = md5Hex([code, filePath, salt]);
|
||||
this.fileHashes[filePath] = hash;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CachingPrecompiler;
|
200
node_modules/ava/lib/cli.js
generated
vendored
Normal file
200
node_modules/ava/lib/cli.js
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const updateNotifier = require('update-notifier');
|
||||
const figures = require('figures');
|
||||
const arrify = require('arrify');
|
||||
const meow = require('meow');
|
||||
const Promise = require('bluebird');
|
||||
const pkgConf = require('pkg-conf');
|
||||
const isCi = require('is-ci');
|
||||
const hasFlag = require('has-flag');
|
||||
const Api = require('../api');
|
||||
const colors = require('./colors');
|
||||
const VerboseReporter = require('./reporters/verbose');
|
||||
const MiniReporter = require('./reporters/mini');
|
||||
const TapReporter = require('./reporters/tap');
|
||||
const Logger = require('./logger');
|
||||
const Watcher = require('./watcher');
|
||||
const babelConfigHelper = require('./babel-config');
|
||||
|
||||
// Bluebird specific
|
||||
Promise.longStackTraces();
|
||||
|
||||
exports.run = () => {
|
||||
const conf = pkgConf.sync('ava');
|
||||
|
||||
const filepath = pkgConf.filepath(conf);
|
||||
const projectDir = filepath === null ? process.cwd() : path.dirname(filepath);
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
ava [<file|directory|glob> ...]
|
||||
|
||||
Options
|
||||
--init Add AVA to your project
|
||||
--fail-fast Stop after first test failure
|
||||
--serial, -s Run tests serially
|
||||
--tap, -t Generate TAP output
|
||||
--verbose, -v Enable verbose output
|
||||
--no-cache Disable the transpiler cache
|
||||
--no-power-assert Disable Power Assert
|
||||
--color Force color output
|
||||
--no-color Disable color output
|
||||
--match, -m Only run tests with matching title (Can be repeated)
|
||||
--watch, -w Re-run tests when tests and source files change
|
||||
--timeout, -T Set global timeout
|
||||
--concurrency, -c Maximum number of test files running at the same time (EXPERIMENTAL)
|
||||
--update-snapshots, -u Update snapshots
|
||||
|
||||
Examples
|
||||
ava
|
||||
ava test.js test2.js
|
||||
ava test-*.js
|
||||
ava test
|
||||
ava --init
|
||||
ava --init foo.js
|
||||
|
||||
Default patterns when no arguments:
|
||||
test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js
|
||||
`, {
|
||||
string: [
|
||||
'_',
|
||||
'match',
|
||||
'timeout',
|
||||
'concurrency'
|
||||
],
|
||||
boolean: [
|
||||
'init',
|
||||
'fail-fast',
|
||||
'serial',
|
||||
'tap',
|
||||
'verbose',
|
||||
'watch',
|
||||
'update-snapshots',
|
||||
'color'
|
||||
],
|
||||
default: {
|
||||
cache: conf.cache,
|
||||
color: 'color' in conf ? conf.color : require('supports-color') !== false,
|
||||
concurrency: conf.concurrency,
|
||||
failFast: conf.failFast,
|
||||
init: conf.init,
|
||||
match: conf.match,
|
||||
powerAssert: conf.powerAssert,
|
||||
serial: conf.serial,
|
||||
tap: conf.tap,
|
||||
timeout: conf.timeout,
|
||||
updateSnapshots: conf.updateSnapshots,
|
||||
verbose: conf.verbose,
|
||||
watch: conf.watch
|
||||
},
|
||||
alias: {
|
||||
t: 'tap',
|
||||
v: 'verbose',
|
||||
s: 'serial',
|
||||
m: 'match',
|
||||
w: 'watch',
|
||||
T: 'timeout',
|
||||
c: 'concurrency',
|
||||
u: 'update-snapshots'
|
||||
}
|
||||
});
|
||||
|
||||
updateNotifier({pkg: cli.pkg}).notify();
|
||||
|
||||
if (cli.flags.init) {
|
||||
require('ava-init')();
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
((hasFlag('--watch') || hasFlag('-w')) && (hasFlag('--tap') || hasFlag('-t'))) ||
|
||||
(conf.watch && conf.tap)
|
||||
) {
|
||||
throw new Error(colors.error(figures.cross) + ' The TAP reporter is not available when using watch mode.');
|
||||
}
|
||||
|
||||
if ((hasFlag('--watch') || hasFlag('-w')) && isCi) {
|
||||
throw new Error(colors.error(figures.cross) + ' Watch mode is not available in CI, as it prevents AVA from terminating.');
|
||||
}
|
||||
|
||||
if (hasFlag('--require') || hasFlag('-r')) {
|
||||
throw new Error(colors.error(figures.cross) + ' The --require and -r flags are deprecated. Requirements should be configured in package.json - see documentation.');
|
||||
}
|
||||
|
||||
// Copy resultant cli.flags into conf for use with Api and elsewhere
|
||||
Object.assign(conf, cli.flags);
|
||||
|
||||
const api = new Api({
|
||||
failFast: conf.failFast,
|
||||
failWithoutAssertions: conf.failWithoutAssertions !== false,
|
||||
serial: conf.serial,
|
||||
require: arrify(conf.require),
|
||||
cacheEnabled: conf.cache !== false,
|
||||
powerAssert: conf.powerAssert !== false,
|
||||
explicitTitles: conf.watch,
|
||||
match: arrify(conf.match),
|
||||
babelConfig: babelConfigHelper.validate(conf.babel),
|
||||
resolveTestsFrom: cli.input.length === 0 ? projectDir : process.cwd(),
|
||||
projectDir,
|
||||
timeout: conf.timeout,
|
||||
concurrency: conf.concurrency ? parseInt(conf.concurrency, 10) : 0,
|
||||
updateSnapshots: conf.updateSnapshots,
|
||||
color: conf.color
|
||||
});
|
||||
|
||||
let reporter;
|
||||
|
||||
if (conf.tap && !conf.watch) {
|
||||
reporter = new TapReporter();
|
||||
} else if (conf.verbose || isCi) {
|
||||
reporter = new VerboseReporter({color: conf.color});
|
||||
} else {
|
||||
reporter = new MiniReporter({color: conf.color, watching: conf.watch});
|
||||
}
|
||||
|
||||
reporter.api = api;
|
||||
const logger = new Logger(reporter);
|
||||
|
||||
logger.start();
|
||||
|
||||
api.on('test-run', runStatus => {
|
||||
reporter.api = runStatus;
|
||||
runStatus.on('test', logger.test);
|
||||
runStatus.on('error', logger.unhandledError);
|
||||
|
||||
runStatus.on('stdout', logger.stdout);
|
||||
runStatus.on('stderr', logger.stderr);
|
||||
});
|
||||
|
||||
const files = cli.input.length ? cli.input : arrify(conf.files);
|
||||
|
||||
if (conf.watch) {
|
||||
try {
|
||||
const watcher = new Watcher(logger, api, files, arrify(conf.source));
|
||||
watcher.observeStdin(process.stdin);
|
||||
} catch (err) {
|
||||
if (err.name === 'AvaError') {
|
||||
// An AvaError may be thrown if `chokidar` is not installed. Log it nicely.
|
||||
console.error(` ${colors.error(figures.cross)} ${err.message}`);
|
||||
logger.exit(1);
|
||||
} else {
|
||||
// Rethrow so it becomes an uncaught exception
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
api.run(files)
|
||||
.then(runStatus => {
|
||||
logger.finish(runStatus);
|
||||
logger.exit(runStatus.failCount > 0 || runStatus.rejectionCount > 0 || runStatus.exceptionCount > 0 ? 1 : 0);
|
||||
})
|
||||
.catch(err => {
|
||||
// Don't swallow exceptions. Note that any expected error should already
|
||||
// have been logged.
|
||||
setImmediate(() => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
57
node_modules/ava/lib/code-excerpt.js
generated
vendored
Normal file
57
node_modules/ava/lib/code-excerpt.js
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const equalLength = require('equal-length');
|
||||
const codeExcerpt = require('code-excerpt');
|
||||
const truncate = require('cli-truncate');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const formatLineNumber = (lineNumber, maxLineNumber) =>
|
||||
' '.repeat(Math.max(0, String(maxLineNumber).length - String(lineNumber).length)) + lineNumber;
|
||||
|
||||
module.exports = (source, options) => {
|
||||
if (!source.isWithinProject || source.isDependency) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const file = source.file;
|
||||
const line = source.line;
|
||||
|
||||
options = options || {};
|
||||
const maxWidth = options.maxWidth || 80;
|
||||
|
||||
let contents;
|
||||
try {
|
||||
contents = fs.readFileSync(file, 'utf8');
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const excerpt = codeExcerpt(contents, line, {around: 1});
|
||||
if (!excerpt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const lines = excerpt.map(item => ({
|
||||
line: item.line,
|
||||
value: truncate(item.value, maxWidth - String(line).length - 5)
|
||||
}));
|
||||
|
||||
const joinedLines = lines.map(line => line.value).join('\n');
|
||||
const extendedLines = equalLength(joinedLines).split('\n');
|
||||
|
||||
return lines
|
||||
.map((item, index) => ({
|
||||
line: item.line,
|
||||
value: extendedLines[index]
|
||||
}))
|
||||
.map(item => {
|
||||
const isErrorSource = item.line === line;
|
||||
|
||||
const lineNumber = formatLineNumber(item.line, line) + ':';
|
||||
const coloredLineNumber = isErrorSource ? lineNumber : chalk.grey(lineNumber);
|
||||
const result = ` ${coloredLineNumber} ${item.value}`;
|
||||
|
||||
return isErrorSource ? chalk.bgRed(result) : result;
|
||||
})
|
||||
.join('\n');
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user