summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2017-07-14 10:52:48 -0700
committerJames M Snell <jasnell@gmail.com>2017-07-17 08:49:02 -0700
commit24f43903b4a2f5aa73a99e6f3d4cc62d559cf94b (patch)
tree9c32bd08c43de8721e54cd846d816fbe6cdf056e /deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js
parentfa73087fcf4bd14db7791120e688a0a508885b64 (diff)
downloadandroid-node-v8-24f43903b4a2f5aa73a99e6f3d4cc62d559cf94b.tar.gz
android-node-v8-24f43903b4a2f5aa73a99e6f3d4cc62d559cf94b.tar.bz2
android-node-v8-24f43903b4a2f5aa73a99e6f3d4cc62d559cf94b.zip
deps: upgrade npm to 5.3.0
PR-URL: https://github.com/nodejs/node/pull/14235 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js')
-rw-r--r--deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js b/deps/npm/node_modules/update-notifier/node_modules/configstore/node_modules/make-dir/index.js
new file mode 100644
index 0000000000..ca1f5e9c6a
--- /dev/null
+++ b/deps/npm/node_modules/update-notifier/node_modules/configstore/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));
+};