aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@ava
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@ava')
-rw-r--r--node_modules/@ava/babel-preset-stage-4/index.js5
-rw-r--r--node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/browser.js10
-rw-r--r--node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/index.js23
-rw-r--r--node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/license21
-rw-r--r--node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/package.json39
-rw-r--r--node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/readme.md44
-rw-r--r--node_modules/@ava/babel-preset-stage-4/package.json51
-rw-r--r--node_modules/@ava/babel-preset-stage-4/plugins/8.json3
-rw-r--r--node_modules/@ava/babel-preset-stage-4/plugins/best-match.js4
-rw-r--r--node_modules/@ava/babel-preset-stage-4/readme.md30
-rw-r--r--node_modules/@ava/pretty-format/.npmignore3
-rwxr-xr-xnode_modules/@ava/pretty-format/LICENSE.md15
-rwxr-xr-xnode_modules/@ava/pretty-format/README.md134
-rw-r--r--node_modules/@ava/pretty-format/index.js397
-rw-r--r--node_modules/@ava/pretty-format/package.json29
-rw-r--r--node_modules/@ava/pretty-format/plugins/ReactElement.js83
-rw-r--r--node_modules/@ava/pretty-format/plugins/ReactTestComponent.js58
-rw-r--r--node_modules/@ava/pretty-format/printString.js7
-rw-r--r--node_modules/@ava/write-file-atomic/LICENSE6
-rw-r--r--node_modules/@ava/write-file-atomic/README.md54
-rw-r--r--node_modules/@ava/write-file-atomic/index.js135
-rw-r--r--node_modules/@ava/write-file-atomic/package.json38
22 files changed, 415 insertions, 774 deletions
diff --git a/node_modules/@ava/babel-preset-stage-4/index.js b/node_modules/@ava/babel-preset-stage-4/index.js
index 823db53ef..fb972935a 100644
--- a/node_modules/@ava/babel-preset-stage-4/index.js
+++ b/node_modules/@ava/babel-preset-stage-4/index.js
@@ -1,9 +1,8 @@
'use strict';
/* eslint-disable import/no-dynamic-require */
-function buildPreset() {
+module.exports = () => {
const plugins = require(`./plugins/best-match`)
.map(module => require(module));
return {plugins};
-}
-module.exports = buildPreset;
+};
diff --git a/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/browser.js b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/browser.js
new file mode 100644
index 000000000..50b9b27cd
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/browser.js
@@ -0,0 +1,10 @@
+'use strict';
+var md5OMatic = require('md5-o-matic');
+
+module.exports = function (input) {
+ if (Array.isArray(input)) {
+ input = input.join('');
+ }
+
+ return md5OMatic(input);
+};
diff --git a/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/index.js b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/index.js
new file mode 100644
index 000000000..c52bddd7c
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/index.js
@@ -0,0 +1,23 @@
+'use strict';
+var crypto = require('crypto');
+
+module.exports = function (input) {
+ var hash = crypto.createHash('md5');
+
+ var update = function (buf) {
+ var inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
+ hash.update(buf, inputEncoding);
+ };
+
+ if (arguments.length > 1) {
+ throw new Error('Too many arguments. Try specifying an array.');
+ }
+
+ if (Array.isArray(input)) {
+ input.forEach(update);
+ } else {
+ update(input);
+ }
+
+ return hash.digest('hex');
+};
diff --git a/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/license b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/license
@@ -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.
diff --git a/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/package.json b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/package.json
new file mode 100644
index 000000000..9dc26627f
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "md5-hex",
+ "version": "1.3.0",
+ "description": "Create a MD5 hash with hex encoding",
+ "license": "MIT",
+ "repository": "sindresorhus/md5-hex",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "browser": "browser.js",
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js",
+ "browser.js"
+ ],
+ "keywords": [
+ "hash",
+ "crypto",
+ "md5",
+ "hex",
+ "buffer",
+ "browser",
+ "browserify"
+ ],
+ "dependencies": {
+ "md5-o-matic": "^0.1.1"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ }
+}
diff --git a/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/readme.md b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/readme.md
new file mode 100644
index 000000000..df40a9415
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/node_modules/md5-hex/readme.md
@@ -0,0 +1,44 @@
+# md5-hex [![Build Status](https://travis-ci.org/sindresorhus/md5-hex.svg?branch=master)](https://travis-ci.org/sindresorhus/md5-hex)
+
+> Create a MD5 hash with hex encoding
+
+*Please don't use MD5 hashes for anything sensitive!*
+
+Checkout [`hasha`](https://github.com/sindresorhus/hasha) if you need something more flexible.
+
+
+## Install
+
+```
+$ npm install --save md5-hex
+```
+
+
+## Usage
+
+```js
+const fs = require('fs');
+const md5Hex = require('md5-hex');
+const buffer = fs.readFileSync('unicorn.png');
+
+md5Hex(buffer);
+//=> '1abcb33beeb811dca15f0ac3e47b88d9'
+```
+
+
+## API
+
+### md5Hex(input)
+
+#### input
+
+Type: `buffer` `string` `array[string|buffer]`
+
+Prefer buffers as they're faster to hash, but strings can be useful for small things.
+
+Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/@ava/babel-preset-stage-4/package.json b/node_modules/@ava/babel-preset-stage-4/package.json
index 3d0b5a5ab..b9ea11af2 100644
--- a/node_modules/@ava/babel-preset-stage-4/package.json
+++ b/node_modules/@ava/babel-preset-stage-4/package.json
@@ -1,42 +1,30 @@
{
"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"
+ "version": "1.1.0",
+ "description": "Efficiently applies the minimum of transforms to run stage 4 code on Node.js 4, 6 and 8",
+ "license": "MIT",
+ "repository": "avajs/babel-preset-stage-4",
+ "author": "Mark Wubben (https://novemberborn.net)",
+ "publishConfig": {
+ "access": "public"
},
"engines": {
"node": ">=4"
},
- "repository": {
- "type": "git",
- "url": "git+https://github.com/avajs/babel-preset-stage-4.git"
+ "scripts": {
+ "test": "xo && ava",
+ "posttest": "xo",
+ "coverage": "nyc npm test"
},
+ "files": [
+ "index.js",
+ "package-hash.js",
+ "plugins"
+ ],
"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",
@@ -51,6 +39,13 @@
"babel-plugin-transform-exponentiation-operator": "^6.8.0",
"package-hash": "^1.2.0"
},
+ "devDependencies": {
+ "ava": "^0.17.0",
+ "coveralls": "^2.11.15",
+ "nyc": "^10.1.2",
+ "proxyquire": "^1.7.10",
+ "xo": "^0.17.1"
+ },
"nyc": {
"reporter": [
"html",
diff --git a/node_modules/@ava/babel-preset-stage-4/plugins/8.json b/node_modules/@ava/babel-preset-stage-4/plugins/8.json
new file mode 100644
index 000000000..2b6732560
--- /dev/null
+++ b/node_modules/@ava/babel-preset-stage-4/plugins/8.json
@@ -0,0 +1,3 @@
+[
+ "babel-plugin-transform-es2015-modules-commonjs"
+]
diff --git a/node_modules/@ava/babel-preset-stage-4/plugins/best-match.js b/node_modules/@ava/babel-preset-stage-4/plugins/best-match.js
index 8743e1b07..89d459790 100644
--- a/node_modules/@ava/babel-preset-stage-4/plugins/best-match.js
+++ b/node_modules/@ava/babel-preset-stage-4/plugins/best-match.js
@@ -4,6 +4,10 @@ const process = require('process');
function getClosestVersion() {
const version = parseFloat(process.versions.node);
+ if (version >= 8) {
+ return 8;
+ }
+
if (version >= 6) {
return 6;
}
diff --git a/node_modules/@ava/babel-preset-stage-4/readme.md b/node_modules/@ava/babel-preset-stage-4/readme.md
index 4003d6442..351cef0cd 100644
--- a/node_modules/@ava/babel-preset-stage-4/readme.md
+++ b/node_modules/@ava/babel-preset-stage-4/readme.md
@@ -1,19 +1,15 @@
-# @ava/babel-preset-stage-4
+# @ava/babel-preset-stage-4 [![Build Status](https://travis-ci.org/avajs/babel-preset-stage-4.svg?branch=master)](https://travis-ci.org/avajs/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.
+> [Babel] preset for use with [AVA]
-Efficiently applies the minimum of transforms to run stage 4 code on Node.js 4
-and 6.
+Aspires to bring ECMAScript stage 4 proposals to AVA's test and helper files.
-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.
+Efficiently applies the minimum of transforms to run stage 4 code on Node.js 4, 6 and 8.
+
+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.
-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
@@ -21,14 +17,14 @@ which are not supported in Node.js 4 even though classes and iterators are.
$ 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.
+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/
+[Babel]: https://babeljs.io
+[node.green]: http://node.green
diff --git a/node_modules/@ava/pretty-format/.npmignore b/node_modules/@ava/pretty-format/.npmignore
deleted file mode 100644
index a2dd48210..000000000
--- a/node_modules/@ava/pretty-format/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-__tests__
-perf
-.travis.yml
diff --git a/node_modules/@ava/pretty-format/LICENSE.md b/node_modules/@ava/pretty-format/LICENSE.md
deleted file mode 100755
index 42a40bb10..000000000
--- a/node_modules/@ava/pretty-format/LICENSE.md
+++ /dev/null
@@ -1,15 +0,0 @@
-## 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.
diff --git a/node_modules/@ava/pretty-format/README.md b/node_modules/@ava/pretty-format/README.md
deleted file mode 100755
index 57e24fc79..000000000
--- a/node_modules/@ava/pretty-format/README.md
+++ /dev/null
@@ -1,134 +0,0 @@
-# @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>
-```
diff --git a/node_modules/@ava/pretty-format/index.js b/node_modules/@ava/pretty-format/index.js
deleted file mode 100644
index b9fc698d8..000000000
--- a/node_modules/@ava/pretty-format/index.js
+++ /dev/null
@@ -1,397 +0,0 @@
-'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;
diff --git a/node_modules/@ava/pretty-format/package.json b/node_modules/@ava/pretty-format/package.json
deleted file mode 100644
index 9cd6a7b19..000000000
--- a/node_modules/@ava/pretty-format/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "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
- }
-}
diff --git a/node_modules/@ava/pretty-format/plugins/ReactElement.js b/node_modules/@ava/pretty-format/plugins/ReactElement.js
deleted file mode 100644
index 0acd7ea10..000000000
--- a/node_modules/@ava/pretty-format/plugins/ReactElement.js
+++ /dev/null
@@ -1,83 +0,0 @@
-'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);
- }
-};
diff --git a/node_modules/@ava/pretty-format/plugins/ReactTestComponent.js b/node_modules/@ava/pretty-format/plugins/ReactTestComponent.js
deleted file mode 100644
index 7d7c79c65..000000000
--- a/node_modules/@ava/pretty-format/plugins/ReactTestComponent.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'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);
- }
-};
diff --git a/node_modules/@ava/pretty-format/printString.js b/node_modules/@ava/pretty-format/printString.js
deleted file mode 100644
index bf5ea0313..000000000
--- a/node_modules/@ava/pretty-format/printString.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-const ESCAPED_CHARACTERS = /(\\|\"|\')/g;
-
-module.exports = function printString(val) {
- return val.replace(ESCAPED_CHARACTERS, '\\$1');
-}
diff --git a/node_modules/@ava/write-file-atomic/LICENSE b/node_modules/@ava/write-file-atomic/LICENSE
new file mode 100644
index 000000000..95e65a770
--- /dev/null
+++ b/node_modules/@ava/write-file-atomic/LICENSE
@@ -0,0 +1,6 @@
+Copyright (c) 2015, Rebecca Turner
+
+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.
+
diff --git a/node_modules/@ava/write-file-atomic/README.md b/node_modules/@ava/write-file-atomic/README.md
new file mode 100644
index 000000000..d74b12710
--- /dev/null
+++ b/node_modules/@ava/write-file-atomic/README.md
@@ -0,0 +1,54 @@
+write-file-atomic
+-----------------
+
+**Forked from https://github.com/npm/write-file-atomic to include https://github.com/npm/write-file-atomic/pull/25, for
+use with [AVA](https://github.com/avajs/ava/).**
+
+---
+
+This is an extension for node's `fs.writeFile` that makes its operation
+atomic and allows you set ownership (uid/gid of the file).
+
+### var writeFileAtomic = require('write-file-atomic')<br>writeFileAtomic(filename, data, [options], callback)
+
+* filename **String**
+* data **String** | **Buffer**
+* options **Object**
+ * chown **Object**
+ * uid **Number**
+ * gid **Number**
+ * encoding **String** | **Null** default = 'utf8'
+ * fsync **Boolean** default = true
+ * mode **Number** default = 438 (aka 0666 in Octal)
+callback **Function**
+
+Atomically and asynchronously writes data to a file, replacing the file if it already
+exists. data can be a string or a buffer.
+
+The file is initially named `filename + "." + murmurhex(__filename, process.pid, ++invocations)`.
+If writeFile completes successfully then, if passed the **chown** option it will change
+the ownership of the file. Finally it renames the file back to the filename you specified. If
+it encounters errors at any of these steps it will attempt to unlink the temporary file and then
+pass the error back to the caller.
+
+If provided, the **chown** option requires both **uid** and **gid** properties or else
+you'll get an error.
+
+The **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'.
+
+If the **fsync** option is **false**, writeFile will skip the final fsync call.
+
+The callback is always invoked with the initial (temporary) filename.
+
+Example:
+
+```javascript
+writeFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}, function (err) {
+ if (err) throw err;
+ console.log('It\'s saved!');
+});
+```
+
+### var writeFileAtomicSync = require('write-file-atomic').sync<br>writeFileAtomicSync(filename, data, [options])
+
+The synchronous version of **writeFileAtomic**. Returns the initial (temporary) filename.
diff --git a/node_modules/@ava/write-file-atomic/index.js b/node_modules/@ava/write-file-atomic/index.js
new file mode 100644
index 000000000..647280670
--- /dev/null
+++ b/node_modules/@ava/write-file-atomic/index.js
@@ -0,0 +1,135 @@
+'use strict'
+module.exports = writeFile
+module.exports.sync = writeFileSync
+module.exports._getTmpname = getTmpname // for testing
+
+var fs = require('graceful-fs')
+var chain = require('slide').chain
+var MurmurHash3 = require('imurmurhash')
+
+var invocations = 0
+function getTmpname (filename) {
+ return filename + '.' +
+ MurmurHash3(__filename)
+ .hash(String(process.pid))
+ .hash(String(++invocations))
+ .result()
+}
+
+function writeFile (filename, data, options, callback) {
+ if (options instanceof Function) {
+ callback = options
+ options = null
+ }
+ if (!options) options = {}
+ fs.realpath(filename, function (_, realname) {
+ _writeFile(realname || filename, data, options, callback)
+ })
+}
+function _writeFile (filename, data, options, callback) {
+ var tmpfile = getTmpname(filename)
+
+ if (options.mode && options.chown) {
+ return thenWriteFile()
+ } else {
+ // Either mode or chown is not explicitly set
+ // Default behavior is to copy it from original file
+ return fs.stat(filename, function (err, stats) {
+ if (err || !stats) return thenWriteFile()
+
+ options = Object.assign({}, options)
+ if (!options.mode) {
+ options.mode = stats.mode
+ }
+ if (!options.chown && process.getuid) {
+ options.chown = { uid: stats.uid, gid: stats.gid }
+ }
+ return thenWriteFile()
+ })
+ }
+
+ function thenWriteFile () {
+ chain([
+ [writeFileAsync, tmpfile, data, options.mode, options.encoding || 'utf8'],
+ options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
+ options.mode && [fs, fs.chmod, tmpfile, options.mode],
+ [fs, fs.rename, tmpfile, filename]
+ ], function (err) {
+ err ? fs.unlink(tmpfile, function () { callback(err, tmpfile) })
+ : callback(null, tmpfile)
+ })
+ }
+
+ // doing this instead of `fs.writeFile` in order to get the ability to
+ // call `fsync`.
+ function writeFileAsync (file, data, mode, encoding, cb) {
+ fs.open(file, 'w', options.mode, function (err, fd) {
+ if (err) return cb(err)
+ if (Buffer.isBuffer(data)) {
+ return fs.write(fd, data, 0, data.length, 0, syncAndClose)
+ } else if (data != null) {
+ return fs.write(fd, String(data), 0, String(encoding), syncAndClose)
+ } else {
+ return syncAndClose()
+ }
+ function syncAndClose (err) {
+ if (err) return cb(err)
+ if (options.fsync !== false) {
+ fs.fsync(fd, function (err) {
+ if (err) return cb(err)
+ fs.close(fd, cb)
+ })
+ } else {
+ fs.close(fd, cb)
+ }
+ }
+ })
+ }
+}
+
+function writeFileSync (filename, data, options) {
+ if (!options) options = {}
+ try {
+ filename = fs.realpathSync(filename)
+ } catch (ex) {
+ // it's ok, it'll happen on a not yet existing file
+ }
+ var tmpfile = getTmpname(filename)
+
+ try {
+ if (!options.mode || !options.chown) {
+ // Either mode or chown is not explicitly set
+ // Default behavior is to copy it from original file
+ try {
+ var stats = fs.statSync(filename)
+ options = Object.assign({}, options)
+ if (!options.mode) {
+ options.mode = stats.mode
+ }
+ if (!options.chown && process.getuid) {
+ options.chown = { uid: stats.uid, gid: stats.gid }
+ }
+ } catch (ex) {
+ // ignore stat errors
+ }
+ }
+
+ var fd = fs.openSync(tmpfile, 'w', options.mode)
+ if (Buffer.isBuffer(data)) {
+ fs.writeSync(fd, data, 0, data.length, 0)
+ } else if (data != null) {
+ fs.writeSync(fd, String(data), 0, String(options.encoding || 'utf8'))
+ }
+ if (options.fsync !== false) {
+ fs.fsyncSync(fd)
+ }
+ fs.closeSync(fd)
+ if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
+ if (options.mode) fs.chmodSync(tmpfile, options.mode)
+ fs.renameSync(tmpfile, filename)
+ return tmpfile
+ } catch (err) {
+ try { fs.unlinkSync(tmpfile) } catch (e) {}
+ throw err
+ }
+}
diff --git a/node_modules/@ava/write-file-atomic/package.json b/node_modules/@ava/write-file-atomic/package.json
new file mode 100644
index 000000000..87b1d0e6c
--- /dev/null
+++ b/node_modules/@ava/write-file-atomic/package.json
@@ -0,0 +1,38 @@
+{
+ "name": "@ava/write-file-atomic",
+ "version": "2.2.0",
+ "description": "Write files in an atomic fashion w/configurable ownership",
+ "main": "index.js",
+ "scripts": {
+ "test": "standard && tap --100 test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/avajs/write-file-atomic"
+ },
+ "keywords": [
+ "writeFile",
+ "atomic"
+ ],
+ "author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org)",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/iarna/write-file-atomic/issues"
+ },
+ "homepage": "https://github.com/iarna/write-file-atomic",
+ "dependencies": {
+ "graceful-fs": "^4.1.11",
+ "imurmurhash": "^0.1.4",
+ "slide": "^1.1.5"
+ },
+ "devDependencies": {
+ "mkdirp": "^0.5.1",
+ "require-inject": "^1.4.0",
+ "rimraf": "^2.5.4",
+ "standard": "^10.0.2",
+ "tap": "^10.3.2"
+ },
+ "files": [
+ "index.js"
+ ]
+}