aboutsummaryrefslogtreecommitdiff
path: root/node_modules/make-dir
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 00:38:50 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 00:40:43 +0200
commit7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch)
tree6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/make-dir
parent963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff)
downloadwallet-core-7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027.tar.xz
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/make-dir')
-rw-r--r--node_modules/make-dir/index.js83
-rw-r--r--node_modules/make-dir/license21
-rw-r--r--node_modules/make-dir/package.json54
-rw-r--r--node_modules/make-dir/readme.md113
4 files changed, 271 insertions, 0 deletions
diff --git a/node_modules/make-dir/index.js b/node_modules/make-dir/index.js
new file mode 100644
index 000000000..ca1f5e9c6
--- /dev/null
+++ b/node_modules/make-dir/index.js
@@ -0,0 +1,83 @@
+'use strict';
+const fs = require('fs');
+const path = require('path');
+const pify = require('pify');
+
+const defaults = {
+ mode: 0o777 & (~process.umask()),
+ fs
+};
+
+// https://github.com/nodejs/node/issues/8987
+// https://github.com/libuv/libuv/pull/1088
+const checkPath = pth => {
+ if (process.platform === 'win32') {
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
+
+ if (pathHasInvalidWinCharacters) {
+ const err = new Error(`Path contains invalid characters: ${pth}`);
+ err.code = 'EINVAL';
+ throw err;
+ }
+ }
+};
+
+module.exports = (input, opts) => Promise.resolve().then(() => {
+ checkPath(input);
+ opts = Object.assign({}, defaults, opts);
+ const fsP = pify(opts.fs);
+
+ const make = pth => {
+ return fsP.mkdir(pth, opts.mode)
+ .then(() => pth)
+ .catch(err => {
+ if (err.code === 'ENOENT') {
+ if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
+ throw err;
+ }
+
+ return make(path.dirname(pth)).then(() => make(pth));
+ }
+
+ return fsP.stat(pth)
+ .then(stats => stats.isDirectory() ? pth : Promise.reject())
+ .catch(() => {
+ throw err;
+ });
+ });
+ };
+
+ return make(path.resolve(input));
+});
+
+module.exports.sync = (input, opts) => {
+ checkPath(input);
+ opts = Object.assign({}, defaults, opts);
+
+ const make = pth => {
+ try {
+ opts.fs.mkdirSync(pth, opts.mode);
+ } catch (err) {
+ if (err.code === 'ENOENT') {
+ if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
+ throw err;
+ }
+
+ make(path.dirname(pth));
+ return make(pth);
+ }
+
+ try {
+ if (!opts.fs.statSync(pth).isDirectory()) {
+ throw new Error();
+ }
+ } catch (_) {
+ throw err;
+ }
+ }
+
+ return pth;
+ };
+
+ return make(path.resolve(input));
+};
diff --git a/node_modules/make-dir/license b/node_modules/make-dir/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/make-dir/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/make-dir/package.json b/node_modules/make-dir/package.json
new file mode 100644
index 000000000..83a1def18
--- /dev/null
+++ b/node_modules/make-dir/package.json
@@ -0,0 +1,54 @@
+{
+ "name": "make-dir",
+ "version": "1.0.0",
+ "description": "Make a directory and its parents if needed - Think `mkdir -p`",
+ "license": "MIT",
+ "repository": "sindresorhus/make-dir",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && nyc ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "mkdir",
+ "mkdirp",
+ "make",
+ "directories",
+ "dir",
+ "dirs",
+ "folders",
+ "directory",
+ "folder",
+ "path",
+ "parent",
+ "parents",
+ "intermediate",
+ "recursively",
+ "recursive",
+ "create",
+ "fs",
+ "filesystem",
+ "file-system"
+ ],
+ "dependencies": {
+ "pify": "^2.3.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "coveralls": "^2.13.0",
+ "graceful-fs": "^4.1.11",
+ "nyc": "^10.2.0",
+ "path-type": "^2.0.0",
+ "tempy": "^0.1.0",
+ "xo": "*"
+ }
+}
diff --git a/node_modules/make-dir/readme.md b/node_modules/make-dir/readme.md
new file mode 100644
index 000000000..23cf23252
--- /dev/null
+++ b/node_modules/make-dir/readme.md
@@ -0,0 +1,113 @@
+# make-dir [![Build Status: macOS & Linux](https://travis-ci.org/sindresorhus/make-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/make-dir) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/e0vtt8y600w91gcs/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/make-dir/branch/master) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/make-dir/badge.svg)](https://coveralls.io/github/sindresorhus/make-dir)
+
+> Make a directory and its parents if needed - Think `mkdir -p`
+
+
+## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp)
+
+- Promise API *(Async/await ready!)*
+- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66)
+- 100% test coverage
+- CI-tested on macOS, Linux, and Windows
+- Actively maintained
+- Doesn't bundle a CLI
+
+
+## Install
+
+```
+$ npm install --save make-dir
+```
+
+
+## Usage
+
+```
+$ pwd
+/Users/sindresorhus/fun
+$ tree
+.
+```
+
+```js
+const makeDir = require('make-dir');
+
+makeDir('unicorn/rainbow/cake').then(path => {
+ console.log(path);
+ //=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
+});
+```
+
+```
+$ tree
+.
+└── unicorn
+ └── rainbow
+ └── cake
+```
+
+Multiple directories:
+
+```js
+const makeDir = require('make-dir');
+
+Promise.all([
+ makeDir('unicorn/rainbow')
+ makeDir('foo/bar')
+]).then(paths => {
+ console.log(paths);
+ /*
+ [
+ '/Users/sindresorhus/fun/unicorn/rainbow',
+ '/Users/sindresorhus/fun/foo/bar'
+ ]
+ */
+});
+```
+
+
+## API
+
+### makeDir(path, [options])
+
+Returns a `Promise` for the path to the created directory.
+
+### makeDir.sync(path, [options])
+
+Returns the path to the created directory.
+
+#### path
+
+Type: `string`
+
+Directory to create.
+
+#### options
+
+Type: `Object`
+
+##### mode
+
+Type: `integer`<br>
+Default: `0o777 & (~process.umask())`
+
+Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
+
+##### fs
+
+Type: `Object`<br>
+Default: `require('fs')`
+
+Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
+
+
+## Related
+
+- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module
+- [del](https://github.com/sindresorhus/del) - Delete files and directories
+- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)